Set eol-style property on all files. Future commits will use the subversion auto-props configuration at http://src.chromium.org/viewvc/chrome/trunk/tools/buildbot/slave/config

git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@109 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
Marshall Greenblatt
2010-10-03 21:04:50 +00:00
parent 5fc6307a6f
commit 46b831304c
182 changed files with 30470 additions and 30470 deletions

View File

@ -1,5 +1,5 @@
# This file is an addendum to the Chromium AUTHORS file. # This file is an addendum to the Chromium AUTHORS file.
# Names should be added to this file like so: # Names should be added to this file like so:
# Name or Organization <email address> # Name or Organization <email address>
Marshall Greenblatt <magreenblatt@gmail.com> Marshall Greenblatt <magreenblatt@gmail.com>

14
DEPS
View File

@ -1,7 +1,7 @@
hooks = [ hooks = [
{ {
# A change to a .gyp, .gypi, or to GYP itself should run the generator. # A change to a .gyp, .gypi, or to GYP itself should run the generator.
"pattern": ".", "pattern": ".",
"action": ["cd", "src\cef", "&", "call", "cef_create_projects.bat", "&", "cd", "..\.."], "action": ["cd", "src\cef", "&", "call", "cef_create_projects.bat", "&", "cd", "..\.."],
}, },
] ]

View File

@ -1,29 +1,29 @@
// Copyright (c) 2008-2009 Marshall A. Greenblatt. Portions Copyright (c) // Copyright (c) 2008-2009 Marshall A. Greenblatt. Portions Copyright (c)
// 2006-2009 Google Inc. All rights reserved. // 2006-2009 Google Inc. All rights reserved.
// //
// Redistribution and use in source and binary forms, with or without // Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are // modification, are permitted provided that the following conditions are
// met: // met:
// //
// * Redistributions of source code must retain the above copyright // * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer. // notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above // * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer // copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the // in the documentation and/or other materials provided with the
// distribution. // distribution.
// * Neither the name of Google Inc. nor the name Chromium Embedded // * Neither the name of Google Inc. nor the name Chromium Embedded
// Framework nor the names of its contributors may be used to endorse // Framework nor the names of its contributors may be used to endorse
// or promote products derived from this software without specific prior // or promote products derived from this software without specific prior
// written permission. // written permission.
// //
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

824
cef.gyp
View File

@ -1,414 +1,414 @@
# Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights # Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights
# reserved. Use of this source code is governed by a BSD-style license that # reserved. Use of this source code is governed by a BSD-style license that
# can be found in the LICENSE file. # can be found in the LICENSE file.
{ {
'variables': { 'variables': {
'chromium_code': 1, 'chromium_code': 1,
}, },
'targets': [ 'targets': [
{ {
'target_name': 'cefclient', 'target_name': 'cefclient',
'type': 'executable', 'type': 'executable',
'msvs_guid': '6617FED9-C5D4-4907-BF55-A90062A6683F', 'msvs_guid': '6617FED9-C5D4-4907-BF55-A90062A6683F',
'dependencies': [ 'dependencies': [
'../third_party/npapi/npapi.gyp:npapi', '../third_party/npapi/npapi.gyp:npapi',
'libcef', 'libcef',
'libcef_dll_wrapper', 'libcef_dll_wrapper',
], ],
'defines': [ 'defines': [
'USING_CEF_SHARED', 'USING_CEF_SHARED',
], ],
'include_dirs': [ 'include_dirs': [
'.', '.',
'..', '..',
], ],
'sources': [ 'sources': [
'tests/cefclient/Resource.h', 'tests/cefclient/Resource.h',
'tests/cefclient/binding_test.cpp', 'tests/cefclient/binding_test.cpp',
'tests/cefclient/binding_test.h', 'tests/cefclient/binding_test.h',
'tests/cefclient/cefclient.cpp', 'tests/cefclient/cefclient.cpp',
'tests/cefclient/cefclient.h', 'tests/cefclient/cefclient.h',
'tests/cefclient/cefclient.ico', 'tests/cefclient/cefclient.ico',
'tests/cefclient/cefclient.rc', 'tests/cefclient/cefclient.rc',
'tests/cefclient/clientplugin.cpp', 'tests/cefclient/clientplugin.cpp',
'tests/cefclient/clientplugin.h', 'tests/cefclient/clientplugin.h',
'tests/cefclient/extension_test.cpp', 'tests/cefclient/extension_test.cpp',
'tests/cefclient/extension_test.h', 'tests/cefclient/extension_test.h',
'tests/cefclient/plugin_test.cpp', 'tests/cefclient/plugin_test.cpp',
'tests/cefclient/plugin_test.h', 'tests/cefclient/plugin_test.h',
'tests/cefclient/res/cefclient.ico', 'tests/cefclient/res/cefclient.ico',
'tests/cefclient/res/logo.jpg', 'tests/cefclient/res/logo.jpg',
'tests/cefclient/res/logoball.jpg', 'tests/cefclient/res/logoball.jpg',
'tests/cefclient/res/small.ico', 'tests/cefclient/res/small.ico',
'tests/cefclient/res/uiplugin.html', 'tests/cefclient/res/uiplugin.html',
'tests/cefclient/resource_util.cpp', 'tests/cefclient/resource_util.cpp',
'tests/cefclient/resource_util.h', 'tests/cefclient/resource_util.h',
'tests/cefclient/scheme_test.cpp', 'tests/cefclient/scheme_test.cpp',
'tests/cefclient/scheme_test.h', 'tests/cefclient/scheme_test.h',
'tests/cefclient/string_util.cpp', 'tests/cefclient/string_util.cpp',
'tests/cefclient/string_util.h', 'tests/cefclient/string_util.h',
'tests/cefclient/uiplugin.cpp', 'tests/cefclient/uiplugin.cpp',
'tests/cefclient/uiplugin.h', 'tests/cefclient/uiplugin.h',
'tests/cefclient/uiplugin_test.cpp', 'tests/cefclient/uiplugin_test.cpp',
'tests/cefclient/uiplugin_test.h', 'tests/cefclient/uiplugin_test.h',
], ],
'link_settings': { 'link_settings': {
'libraries': [ 'libraries': [
'-lcomctl32.lib', '-lcomctl32.lib',
'-lshlwapi.lib', '-lshlwapi.lib',
'-lrpcrt4.lib', '-lrpcrt4.lib',
'-lopengl32.lib', '-lopengl32.lib',
'-lglu32.lib', '-lglu32.lib',
], ],
}, },
'conditions': [ 'conditions': [
['OS=="win"', { ['OS=="win"', {
'msvs_settings': { 'msvs_settings': {
'VCLinkerTool': { 'VCLinkerTool': {
# Set /SUBSYSTEM:WINDOWS. # Set /SUBSYSTEM:WINDOWS.
'SubSystem': '2', 'SubSystem': '2',
'EntryPointSymbol' : 'wWinMainCRTStartup', 'EntryPointSymbol' : 'wWinMainCRTStartup',
}, },
}, },
}], }],
], ],
}, },
{ {
'target_name': 'cef_unittests', 'target_name': 'cef_unittests',
'type': 'executable', 'type': 'executable',
'msvs_guid': '8500027C-B11A-11DE-A16E-B80256D89593', 'msvs_guid': '8500027C-B11A-11DE-A16E-B80256D89593',
'dependencies': [ 'dependencies': [
'../base/base.gyp:base', '../base/base.gyp:base',
'../base/base.gyp:base_i18n', '../base/base.gyp:base_i18n',
'../base/base.gyp:test_support_base', '../base/base.gyp:test_support_base',
'../testing/gtest.gyp:gtest', '../testing/gtest.gyp:gtest',
'../third_party/icu/icu.gyp:icui18n', '../third_party/icu/icu.gyp:icui18n',
'../third_party/icu/icu.gyp:icuuc', '../third_party/icu/icu.gyp:icuuc',
'libcef', 'libcef',
'libcef_dll_wrapper', 'libcef_dll_wrapper',
], ],
'sources': [ 'sources': [
'tests/unittests/request_unittest.cc', 'tests/unittests/request_unittest.cc',
'tests/unittests/run_all_unittests.cc', 'tests/unittests/run_all_unittests.cc',
'tests/unittests/stream_unittest.cc', 'tests/unittests/stream_unittest.cc',
'tests/unittests/test_handler.h', 'tests/unittests/test_handler.h',
'tests/unittests/test_suite.h', 'tests/unittests/test_suite.h',
'tests/unittests/v8_unittest.cc', 'tests/unittests/v8_unittest.cc',
], ],
'include_dirs': [ 'include_dirs': [
'.', '.',
'..', '..',
], ],
}, },
{ {
'target_name': 'patcher', 'target_name': 'patcher',
'type': 'none', 'type': 'none',
'msvs_guid': 'A6D0953E-899E-4C60-AB6B-CAE75A44B8E6', 'msvs_guid': 'A6D0953E-899E-4C60-AB6B-CAE75A44B8E6',
'actions': [ 'actions': [
{ {
'action_name': 'patch_source', 'action_name': 'patch_source',
'msvs_cygwin_shell': 0, 'msvs_cygwin_shell': 0,
'inputs': [ 'inputs': [
'tools/patch_source.bat', 'tools/patch_source.bat',
], ],
'outputs': [ 'outputs': [
'tools/patch_source.bat.output', 'tools/patch_source.bat.output',
], ],
'action': ['', '<@(_inputs)'], 'action': ['', '<@(_inputs)'],
}, },
], ],
}, },
{ {
'target_name': 'libcef', 'target_name': 'libcef',
'type': 'shared_library', 'type': 'shared_library',
'msvs_guid': 'C13650D5-CF1A-4259-BE45-B1EBA6280E47', 'msvs_guid': 'C13650D5-CF1A-4259-BE45-B1EBA6280E47',
'dependencies': [ 'dependencies': [
'../app/app.gyp:app_base', '../app/app.gyp:app_base',
'../base/base.gyp:base', '../base/base.gyp:base',
'../base/base.gyp:base_i18n', '../base/base.gyp:base_i18n',
'../breakpad/breakpad.gyp:breakpad_handler', '../breakpad/breakpad.gyp:breakpad_handler',
'../build/temp_gyp/googleurl.gyp:googleurl', '../build/temp_gyp/googleurl.gyp:googleurl',
'../gfx/gfx.gyp:gfx', '../gfx/gfx.gyp:gfx',
'../media/media.gyp:media', '../media/media.gyp:media',
'../net/net.gyp:net', '../net/net.gyp:net',
'../net/net.gyp:net_resources', '../net/net.gyp:net_resources',
'../printing/printing.gyp:printing', '../printing/printing.gyp:printing',
'../sdch/sdch.gyp:sdch', '../sdch/sdch.gyp:sdch',
'../skia/skia.gyp:skia', '../skia/skia.gyp:skia',
'../third_party/bzip2/bzip2.gyp:bzip2', '../third_party/bzip2/bzip2.gyp:bzip2',
'../third_party/ffmpeg/ffmpeg.gyp:ffmpeg', '../third_party/ffmpeg/ffmpeg.gyp:ffmpeg',
'../third_party/icu/icu.gyp:icui18n', '../third_party/icu/icu.gyp:icui18n',
'../third_party/icu/icu.gyp:icuuc', '../third_party/icu/icu.gyp:icuuc',
'../third_party/libjpeg/libjpeg.gyp:libjpeg', '../third_party/libjpeg/libjpeg.gyp:libjpeg',
'../third_party/libpng/libpng.gyp:libpng', '../third_party/libpng/libpng.gyp:libpng',
'../third_party/libxslt/libxslt.gyp:libxslt', '../third_party/libxslt/libxslt.gyp:libxslt',
'../third_party/mesa/mesa.gyp:osmesa', '../third_party/mesa/mesa.gyp:osmesa',
'../third_party/modp_b64/modp_b64.gyp:modp_b64', '../third_party/modp_b64/modp_b64.gyp:modp_b64',
'../third_party/WebKit/JavaScriptCore/JavaScriptCore.gyp/JavaScriptCore.gyp:pcre', '../third_party/WebKit/JavaScriptCore/JavaScriptCore.gyp/JavaScriptCore.gyp:pcre',
'../third_party/WebKit/JavaScriptCore/JavaScriptCore.gyp/JavaScriptCore.gyp:wtf', '../third_party/WebKit/JavaScriptCore/JavaScriptCore.gyp/JavaScriptCore.gyp:wtf',
'../third_party/WebKit/WebCore/WebCore.gyp/WebCore.gyp:webcore', '../third_party/WebKit/WebCore/WebCore.gyp/WebCore.gyp:webcore',
'../third_party/WebKit/WebKit/chromium/WebKit.gyp:webkit', '../third_party/WebKit/WebKit/chromium/WebKit.gyp:webkit',
'../third_party/zlib/zlib.gyp:zlib', '../third_party/zlib/zlib.gyp:zlib',
'../webkit/support/webkit_support.gyp:appcache', '../webkit/support/webkit_support.gyp:appcache',
'../webkit/support/webkit_support.gyp:blob', '../webkit/support/webkit_support.gyp:blob',
'../webkit/support/webkit_support.gyp:database', '../webkit/support/webkit_support.gyp:database',
'../webkit/support/webkit_support.gyp:fileapi', '../webkit/support/webkit_support.gyp:fileapi',
'../webkit/support/webkit_support.gyp:glue', '../webkit/support/webkit_support.gyp:glue',
'../webkit/support/webkit_support.gyp:webkit_resources', '../webkit/support/webkit_support.gyp:webkit_resources',
'../webkit/support/webkit_support.gyp:webkit_strings', '../webkit/support/webkit_support.gyp:webkit_strings',
'libcef_static', 'libcef_static',
], ],
'defines': [ 'defines': [
'BUILDING_CEF_SHARED', 'BUILDING_CEF_SHARED',
], ],
'include_dirs': [ 'include_dirs': [
'.', '.',
'..', '..',
], ],
# Avoid "RC1102: internal error : too many arguments to RCPP" error by # Avoid "RC1102: internal error : too many arguments to RCPP" error by
# explicitly specifying a short list of resource include directories. # explicitly specifying a short list of resource include directories.
'resource_include_dirs' : [ 'resource_include_dirs' : [
'.', '.',
'..', '..',
], ],
'sources': [ 'sources': [
'$(OutDir)/obj/global_intermediate/webkit/webkit_resources.rc', '$(OutDir)/obj/global_intermediate/webkit/webkit_resources.rc',
'$(OutDir)/obj/global_intermediate/webkit/webkit_strings_en-US.rc', '$(OutDir)/obj/global_intermediate/webkit/webkit_strings_en-US.rc',
'include/cef.h', 'include/cef.h',
'include/cef_capi.h', 'include/cef_capi.h',
'include/cef_export.h', 'include/cef_export.h',
'include/cef_nplugin.h', 'include/cef_nplugin.h',
'include/cef_nplugin_capi.h', 'include/cef_nplugin_capi.h',
'include/cef_ptr.h', 'include/cef_ptr.h',
'include/cef_string.h', 'include/cef_string.h',
'include/cef_string_list.h', 'include/cef_string_list.h',
'include/cef_string_map.h', 'include/cef_string_map.h',
'include/cef_types.h', 'include/cef_types.h',
'include/cef_types_win.h', 'include/cef_types_win.h',
'include/cef_win.h', 'include/cef_win.h',
'libcef_dll/cef_logging.h', 'libcef_dll/cef_logging.h',
'libcef_dll/cpptoc/browser_cpptoc.cc', 'libcef_dll/cpptoc/browser_cpptoc.cc',
'libcef_dll/cpptoc/browser_cpptoc.h', 'libcef_dll/cpptoc/browser_cpptoc.h',
'libcef_dll/cpptoc/cpptoc.h', 'libcef_dll/cpptoc/cpptoc.h',
'libcef_dll/cpptoc/frame_cpptoc.cc', 'libcef_dll/cpptoc/frame_cpptoc.cc',
'libcef_dll/cpptoc/frame_cpptoc.h', 'libcef_dll/cpptoc/frame_cpptoc.h',
'libcef_dll/cpptoc/post_data_cpptoc.cc', 'libcef_dll/cpptoc/post_data_cpptoc.cc',
'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/request_cpptoc.cc', 'libcef_dll/cpptoc/request_cpptoc.cc',
'libcef_dll/cpptoc/request_cpptoc.h', 'libcef_dll/cpptoc/request_cpptoc.h',
'libcef_dll/cpptoc/stream_reader_cpptoc.cc', 'libcef_dll/cpptoc/stream_reader_cpptoc.cc',
'libcef_dll/cpptoc/stream_reader_cpptoc.h', 'libcef_dll/cpptoc/stream_reader_cpptoc.h',
'libcef_dll/cpptoc/stream_writer_cpptoc.cc', 'libcef_dll/cpptoc/stream_writer_cpptoc.cc',
'libcef_dll/cpptoc/stream_writer_cpptoc.h', 'libcef_dll/cpptoc/stream_writer_cpptoc.h',
'libcef_dll/cpptoc/v8value_cpptoc.cc', 'libcef_dll/cpptoc/v8value_cpptoc.cc',
'libcef_dll/cpptoc/v8value_cpptoc.h', 'libcef_dll/cpptoc/v8value_cpptoc.h',
'libcef_dll/ctocpp/ctocpp.h', 'libcef_dll/ctocpp/ctocpp.h',
'libcef_dll/ctocpp/handler_ctocpp.cc', 'libcef_dll/ctocpp/handler_ctocpp.cc',
'libcef_dll/ctocpp/handler_ctocpp.h', 'libcef_dll/ctocpp/handler_ctocpp.h',
'libcef_dll/ctocpp/read_handler_ctocpp.cc', 'libcef_dll/ctocpp/read_handler_ctocpp.cc',
'libcef_dll/ctocpp/read_handler_ctocpp.h', 'libcef_dll/ctocpp/read_handler_ctocpp.h',
'libcef_dll/ctocpp/scheme_handler_ctocpp.cc', 'libcef_dll/ctocpp/scheme_handler_ctocpp.cc',
'libcef_dll/ctocpp/scheme_handler_ctocpp.h', 'libcef_dll/ctocpp/scheme_handler_ctocpp.h',
'libcef_dll/ctocpp/scheme_handler_factory_ctocpp.cc', 'libcef_dll/ctocpp/scheme_handler_factory_ctocpp.cc',
'libcef_dll/ctocpp/scheme_handler_factory_ctocpp.h', 'libcef_dll/ctocpp/scheme_handler_factory_ctocpp.h',
'libcef_dll/ctocpp/task_ctocpp.cc', 'libcef_dll/ctocpp/task_ctocpp.cc',
'libcef_dll/ctocpp/task_ctocpp.h', 'libcef_dll/ctocpp/task_ctocpp.h',
'libcef_dll/ctocpp/v8handler_ctocpp.cc', 'libcef_dll/ctocpp/v8handler_ctocpp.cc',
'libcef_dll/ctocpp/v8handler_ctocpp.h', 'libcef_dll/ctocpp/v8handler_ctocpp.h',
'libcef_dll/ctocpp/write_handler_ctocpp.cc', 'libcef_dll/ctocpp/write_handler_ctocpp.cc',
'libcef_dll/ctocpp/write_handler_ctocpp.h', 'libcef_dll/ctocpp/write_handler_ctocpp.h',
'libcef_dll/libcef_dll.cc', 'libcef_dll/libcef_dll.cc',
'libcef_dll/libcef_dll.rc', 'libcef_dll/libcef_dll.rc',
'libcef_dll/resource.h', 'libcef_dll/resource.h',
'libcef_dll/transfer_util.cpp', 'libcef_dll/transfer_util.cpp',
'libcef_dll/transfer_util.h', 'libcef_dll/transfer_util.h',
], ],
'link_settings': { 'link_settings': {
'libraries': [ 'libraries': [
'-lcomctl32.lib', '-lcomctl32.lib',
], ],
}, },
}, },
{ {
'target_name': 'libcef_dll_wrapper', 'target_name': 'libcef_dll_wrapper',
'type': 'static_library', 'type': 'static_library',
'msvs_guid': 'A9D6DC71-C0DC-4549-AEA0-3B15B44E86A9', 'msvs_guid': 'A9D6DC71-C0DC-4549-AEA0-3B15B44E86A9',
'dependencies': [ 'dependencies': [
'../third_party/npapi/npapi.gyp:npapi', '../third_party/npapi/npapi.gyp:npapi',
'libcef', 'libcef',
], ],
'defines': [ 'defines': [
'USING_CEF_SHARED', 'USING_CEF_SHARED',
], ],
'include_dirs': [ 'include_dirs': [
'.', '.',
'..', '..',
], ],
'sources': [ 'sources': [
'libcef_dll/cef_logging.h', 'libcef_dll/cef_logging.h',
'libcef_dll/cpptoc/cpptoc.h', 'libcef_dll/cpptoc/cpptoc.h',
'libcef_dll/cpptoc/handler_cpptoc.cc', 'libcef_dll/cpptoc/handler_cpptoc.cc',
'libcef_dll/cpptoc/handler_cpptoc.h', 'libcef_dll/cpptoc/handler_cpptoc.h',
'libcef_dll/cpptoc/read_handler_cpptoc.cc', 'libcef_dll/cpptoc/read_handler_cpptoc.cc',
'libcef_dll/cpptoc/read_handler_cpptoc.h', 'libcef_dll/cpptoc/read_handler_cpptoc.h',
'libcef_dll/cpptoc/scheme_handler_cpptoc.cc', 'libcef_dll/cpptoc/scheme_handler_cpptoc.cc',
'libcef_dll/cpptoc/scheme_handler_cpptoc.h', 'libcef_dll/cpptoc/scheme_handler_cpptoc.h',
'libcef_dll/cpptoc/scheme_handler_factory_cpptoc.cc', 'libcef_dll/cpptoc/scheme_handler_factory_cpptoc.cc',
'libcef_dll/cpptoc/scheme_handler_factory_cpptoc.h', 'libcef_dll/cpptoc/scheme_handler_factory_cpptoc.h',
'libcef_dll/cpptoc/v8handler_cpptoc.cc', 'libcef_dll/cpptoc/v8handler_cpptoc.cc',
'libcef_dll/cpptoc/v8handler_cpptoc.h', 'libcef_dll/cpptoc/v8handler_cpptoc.h',
'libcef_dll/cpptoc/write_handler_cpptoc.cc', 'libcef_dll/cpptoc/write_handler_cpptoc.cc',
'libcef_dll/cpptoc/write_handler_cpptoc.h', 'libcef_dll/cpptoc/write_handler_cpptoc.h',
'libcef_dll/ctocpp/browser_ctocpp.cc', 'libcef_dll/ctocpp/browser_ctocpp.cc',
'libcef_dll/ctocpp/browser_ctocpp.h', 'libcef_dll/ctocpp/browser_ctocpp.h',
'libcef_dll/ctocpp/ctocpp.h', 'libcef_dll/ctocpp/ctocpp.h',
'libcef_dll/ctocpp/frame_ctocpp.cc', 'libcef_dll/ctocpp/frame_ctocpp.cc',
'libcef_dll/ctocpp/frame_ctocpp.h', 'libcef_dll/ctocpp/frame_ctocpp.h',
'libcef_dll/ctocpp/post_data_ctocpp.cc', 'libcef_dll/ctocpp/post_data_ctocpp.cc',
'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/request_ctocpp.cc', 'libcef_dll/ctocpp/request_ctocpp.cc',
'libcef_dll/ctocpp/request_ctocpp.h', 'libcef_dll/ctocpp/request_ctocpp.h',
'libcef_dll/ctocpp/stream_reader_ctocpp.cc', 'libcef_dll/ctocpp/stream_reader_ctocpp.cc',
'libcef_dll/ctocpp/stream_reader_ctocpp.h', 'libcef_dll/ctocpp/stream_reader_ctocpp.h',
'libcef_dll/ctocpp/stream_writer_ctocpp.cc', 'libcef_dll/ctocpp/stream_writer_ctocpp.cc',
'libcef_dll/ctocpp/stream_writer_ctocpp.h', 'libcef_dll/ctocpp/stream_writer_ctocpp.h',
'libcef_dll/cpptoc/task_cpptoc.cc', 'libcef_dll/cpptoc/task_cpptoc.cc',
'libcef_dll/cpptoc/task_cpptoc.h', 'libcef_dll/cpptoc/task_cpptoc.h',
'libcef_dll/ctocpp/v8value_ctocpp.cc', 'libcef_dll/ctocpp/v8value_ctocpp.cc',
'libcef_dll/ctocpp/v8value_ctocpp.h', 'libcef_dll/ctocpp/v8value_ctocpp.h',
'libcef_dll/transfer_util.cpp', 'libcef_dll/transfer_util.cpp',
'libcef_dll/transfer_util.h', 'libcef_dll/transfer_util.h',
'libcef_dll/wrapper/libcef_dll_wrapper.cc', 'libcef_dll/wrapper/libcef_dll_wrapper.cc',
], ],
}, },
{ {
'target_name': 'libcef_static', 'target_name': 'libcef_static',
'type': 'static_library', 'type': 'static_library',
'msvs_guid': 'FA39524D-3067-4141-888D-28A86C66F2B9', 'msvs_guid': 'FA39524D-3067-4141-888D-28A86C66F2B9',
'defines': [ 'defines': [
'BUILDING_CEF_SHARED', 'BUILDING_CEF_SHARED',
], ],
'include_dirs': [ 'include_dirs': [
'.', '.',
'..', '..',
'../third_party/WebKit/WebKit/chromium/public' '../third_party/WebKit/WebKit/chromium/public'
], ],
'dependencies': [ 'dependencies': [
'../app/app.gyp:app_base', '../app/app.gyp:app_base',
'../base/base.gyp:base', '../base/base.gyp:base',
'../base/base.gyp:base_i18n', '../base/base.gyp:base_i18n',
'../breakpad/breakpad.gyp:breakpad_handler', '../breakpad/breakpad.gyp:breakpad_handler',
'../build/temp_gyp/googleurl.gyp:googleurl', '../build/temp_gyp/googleurl.gyp:googleurl',
'../gfx/gfx.gyp:gfx', '../gfx/gfx.gyp:gfx',
'../media/media.gyp:media', '../media/media.gyp:media',
'../net/net.gyp:net', '../net/net.gyp:net',
'../net/net.gyp:net_resources', '../net/net.gyp:net_resources',
'../printing/printing.gyp:printing', '../printing/printing.gyp:printing',
'../sdch/sdch.gyp:sdch', '../sdch/sdch.gyp:sdch',
'../skia/skia.gyp:skia', '../skia/skia.gyp:skia',
'../third_party/bzip2/bzip2.gyp:bzip2', '../third_party/bzip2/bzip2.gyp:bzip2',
'../third_party/ffmpeg/ffmpeg.gyp:ffmpeg', '../third_party/ffmpeg/ffmpeg.gyp:ffmpeg',
'../third_party/icu/icu.gyp:icui18n', '../third_party/icu/icu.gyp:icui18n',
'../third_party/icu/icu.gyp:icuuc', '../third_party/icu/icu.gyp:icuuc',
'../third_party/libjpeg/libjpeg.gyp:libjpeg', '../third_party/libjpeg/libjpeg.gyp:libjpeg',
'../third_party/libpng/libpng.gyp:libpng', '../third_party/libpng/libpng.gyp:libpng',
'../third_party/libxslt/libxslt.gyp:libxslt', '../third_party/libxslt/libxslt.gyp:libxslt',
'../third_party/mesa/mesa.gyp:osmesa', '../third_party/mesa/mesa.gyp:osmesa',
'../third_party/modp_b64/modp_b64.gyp:modp_b64', '../third_party/modp_b64/modp_b64.gyp:modp_b64',
'../third_party/WebKit/JavaScriptCore/JavaScriptCore.gyp/JavaScriptCore.gyp:pcre', '../third_party/WebKit/JavaScriptCore/JavaScriptCore.gyp/JavaScriptCore.gyp:pcre',
'../third_party/WebKit/JavaScriptCore/JavaScriptCore.gyp/JavaScriptCore.gyp:wtf', '../third_party/WebKit/JavaScriptCore/JavaScriptCore.gyp/JavaScriptCore.gyp:wtf',
'../third_party/WebKit/WebCore/WebCore.gyp/WebCore.gyp:webcore', '../third_party/WebKit/WebCore/WebCore.gyp/WebCore.gyp:webcore',
'../third_party/WebKit/WebKit/chromium/WebKit.gyp:webkit', '../third_party/WebKit/WebKit/chromium/WebKit.gyp:webkit',
'../third_party/zlib/zlib.gyp:zlib', '../third_party/zlib/zlib.gyp:zlib',
'../webkit/support/webkit_support.gyp:appcache', '../webkit/support/webkit_support.gyp:appcache',
'../webkit/support/webkit_support.gyp:blob', '../webkit/support/webkit_support.gyp:blob',
'../webkit/support/webkit_support.gyp:database', '../webkit/support/webkit_support.gyp:database',
'../webkit/support/webkit_support.gyp:fileapi', '../webkit/support/webkit_support.gyp:fileapi',
'../webkit/support/webkit_support.gyp:glue', '../webkit/support/webkit_support.gyp:glue',
'../webkit/support/webkit_support.gyp:webkit_resources', '../webkit/support/webkit_support.gyp:webkit_resources',
'../webkit/support/webkit_support.gyp:webkit_strings', '../webkit/support/webkit_support.gyp:webkit_strings',
], ],
'sources': [ 'sources': [
'include/cef.h', 'include/cef.h',
'include/cef_export.h', 'include/cef_export.h',
'include/cef_nplugin.h', 'include/cef_nplugin.h',
'include/cef_ptr.h', 'include/cef_ptr.h',
'include/cef_string.h', 'include/cef_string.h',
'include/cef_string_list.h', 'include/cef_string_list.h',
'include/cef_string_map.h', 'include/cef_string_map.h',
'include/cef_types.h', 'include/cef_types.h',
'include/cef_types_win.h', 'include/cef_types_win.h',
'include/cef_win.h', 'include/cef_win.h',
'libcef/browser_appcache_system.cc', 'libcef/browser_appcache_system.cc',
'libcef/browser_appcache_system.h', 'libcef/browser_appcache_system.h',
'libcef/browser_database_system.cc', 'libcef/browser_database_system.cc',
'libcef/browser_database_system.h', 'libcef/browser_database_system.h',
'libcef/browser_drag_delegate.cc', 'libcef/browser_drag_delegate.cc',
'libcef/browser_drag_delegate.h', 'libcef/browser_drag_delegate.h',
'libcef/browser_drop_delegate.cc', 'libcef/browser_drop_delegate.cc',
'libcef/browser_drop_delegate.h', 'libcef/browser_drop_delegate.h',
'libcef/browser_file_system.cc', 'libcef/browser_file_system.cc',
'libcef/browser_file_system.h', 'libcef/browser_file_system.h',
'libcef/browser_impl.cc', 'libcef/browser_impl.cc',
'libcef/browser_impl.h', 'libcef/browser_impl.h',
'libcef/browser_impl_win.cc', 'libcef/browser_impl_win.cc',
'libcef/browser_navigation_controller.cc', 'libcef/browser_navigation_controller.cc',
'libcef/browser_navigation_controller.h', 'libcef/browser_navigation_controller.h',
'libcef/browser_request_context.cc', 'libcef/browser_request_context.cc',
'libcef/browser_request_context.h', 'libcef/browser_request_context.h',
'libcef/browser_resource_loader_bridge.cc', 'libcef/browser_resource_loader_bridge.cc',
'libcef/browser_resource_loader_bridge.h', 'libcef/browser_resource_loader_bridge.h',
'libcef/browser_socket_stream_bridge.cc', 'libcef/browser_socket_stream_bridge.cc',
'libcef/browser_socket_stream_bridge.h', 'libcef/browser_socket_stream_bridge.h',
'libcef/browser_webcookiejar_impl.cc', 'libcef/browser_webcookiejar_impl.cc',
'libcef/browser_webcookiejar_impl.h', 'libcef/browser_webcookiejar_impl.h',
'libcef/browser_webblobregistry_impl.cc', 'libcef/browser_webblobregistry_impl.cc',
'libcef/browser_webblobregistry_impl.h', 'libcef/browser_webblobregistry_impl.h',
'libcef/browser_webkit_glue.cc', 'libcef/browser_webkit_glue.cc',
'libcef/browser_webkit_glue.h', 'libcef/browser_webkit_glue.h',
'libcef/browser_webkit_glue_win.cc', 'libcef/browser_webkit_glue_win.cc',
'libcef/browser_webkit_init.h', 'libcef/browser_webkit_init.h',
'libcef/browser_webview_delegate.cc', 'libcef/browser_webview_delegate.cc',
'libcef/browser_webview_delegate.h', 'libcef/browser_webview_delegate.h',
'libcef/browser_webview_delegate_win.cc', 'libcef/browser_webview_delegate_win.cc',
'libcef/cef_context.cc', 'libcef/cef_context.cc',
'libcef/cef_context.h', 'libcef/cef_context.h',
'libcef/cef_process.cc', 'libcef/cef_process.cc',
'libcef/cef_process.h', 'libcef/cef_process.h',
'libcef/cef_process_io_thread.cc', 'libcef/cef_process_io_thread.cc',
'libcef/cef_process_io_thread.h', 'libcef/cef_process_io_thread.h',
'libcef/cef_process_sub_thread.cc', 'libcef/cef_process_sub_thread.cc',
'libcef/cef_process_sub_thread.h', 'libcef/cef_process_sub_thread.h',
'libcef/cef_process_ui_thread.cc', 'libcef/cef_process_ui_thread.cc',
'libcef/cef_process_ui_thread.h', 'libcef/cef_process_ui_thread.h',
'libcef/cef_string.c', 'libcef/cef_string.c',
'libcef/cef_string_list.cc', 'libcef/cef_string_list.cc',
'libcef/cef_string_map.cc', 'libcef/cef_string_map.cc',
'libcef/cef_thread.cc', 'libcef/cef_thread.cc',
'libcef/cef_thread.h', 'libcef/cef_thread.h',
'libcef/printing/print_settings.cc', 'libcef/printing/print_settings.cc',
'libcef/printing/print_settings.h', 'libcef/printing/print_settings.h',
'libcef/printing/win_printing_context.cc', 'libcef/printing/win_printing_context.cc',
'libcef/printing/win_printing_context.h', 'libcef/printing/win_printing_context.h',
'libcef/request_impl.cc', 'libcef/request_impl.cc',
'libcef/request_impl.h', 'libcef/request_impl.h',
'libcef/scheme_impl.cc', 'libcef/scheme_impl.cc',
'libcef/simple_clipboard_impl.cc', 'libcef/simple_clipboard_impl.cc',
'libcef/stream_impl.cc', 'libcef/stream_impl.cc',
'libcef/stream_impl.h', 'libcef/stream_impl.h',
'libcef/tracker.h', 'libcef/tracker.h',
'libcef/v8_impl.cc', 'libcef/v8_impl.cc',
'libcef/v8_impl.h', 'libcef/v8_impl.h',
'libcef/webview_host.cc', 'libcef/webview_host.cc',
'libcef/webview_host.h', 'libcef/webview_host.h',
'libcef/webwidget_host.cc', 'libcef/webwidget_host.cc',
'libcef/webwidget_host.h', 'libcef/webwidget_host.h',
], ],
}, },
] ]
} }

View File

@ -1,10 +1,10 @@
# Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights # Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights
# reserved. Use of this source code is governed by a BSD-style license that # reserved. Use of this source code is governed by a BSD-style license that
# can be found in the LICENSE file. # can be found in the LICENSE file.
{ {
'variables': { 'variables': {
# Directory for CEF source files. # Directory for CEF source files.
'cef_directory' : '<!(echo %CEF_DIRECTORY%)', 'cef_directory' : '<!(echo %CEF_DIRECTORY%)',
}, },
} }

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,41 +1,41 @@
// Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights // Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights
// reserved. // reserved.
// //
// Redistribution and use in source and binary forms, with or without // Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are // modification, are permitted provided that the following conditions are
// met: // met:
// //
// * Redistributions of source code must retain the above copyright // * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer. // notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above // * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer // copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the // in the documentation and/or other materials provided with the
// distribution. // distribution.
// * Neither the name of Google Inc. nor the name Chromium Embedded // * Neither the name of Google Inc. nor the name Chromium Embedded
// Framework nor the names of its contributors may be used to endorse // Framework nor the names of its contributors may be used to endorse
// or promote products derived from this software without specific prior // or promote products derived from this software without specific prior
// written permission. // written permission.
// //
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifdef _MSC_VER // MSVC #ifdef _MSC_VER // MSVC
#ifdef BUILDING_CEF_SHARED #ifdef BUILDING_CEF_SHARED
#define CEF_EXPORT __declspec(dllexport) #define CEF_EXPORT __declspec(dllexport)
#elif USING_CEF_SHARED #elif USING_CEF_SHARED
#define CEF_EXPORT __declspec(dllimport) #define CEF_EXPORT __declspec(dllimport)
#else #else
#define CEF_EXPORT #define CEF_EXPORT
#endif // BUILDING_CEF_SHARED #endif // BUILDING_CEF_SHARED
#define CEF_CALLBACK __stdcall #define CEF_CALLBACK __stdcall
#endif // MSVC #endif // MSVC

View File

@ -1,85 +1,85 @@
// Copyright (c) 2008 Marshall A. Greenblatt. All rights reserved. // Copyright (c) 2008 Marshall A. Greenblatt. All rights reserved.
// //
// Redistribution and use in source and binary forms, with or without // Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are // modification, are permitted provided that the following conditions are
// met: // met:
// //
// * Redistributions of source code must retain the above copyright // * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer. // notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above // * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer // copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the // in the documentation and/or other materials provided with the
// distribution. // distribution.
// * Neither the name of Google Inc. nor the name Chromium Embedded // * Neither the name of Google Inc. nor the name Chromium Embedded
// Framework nor the names of its contributors may be used to endorse // Framework nor the names of its contributors may be used to endorse
// or promote products derived from this software without specific prior // or promote products derived from this software without specific prior
// written permission. // written permission.
// //
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef _CEF_PLUGIN_H #ifndef _CEF_PLUGIN_H
#define _CEF_PLUGIN_H #define _CEF_PLUGIN_H
#include <string> #include <string>
#include <vector> #include <vector>
#include "third_party/npapi/bindings/npapi.h" #include "third_party/npapi/bindings/npapi.h"
#include "third_party/npapi/bindings/nphostapi.h" #include "third_party/npapi/bindings/nphostapi.h"
// Netscape plugins are normally built at separate DLLs that are loaded by the // Netscape plugins are normally built at separate DLLs that are loaded by the
// browser when needed. This interface supports the creation of plugins that // browser when needed. This interface supports the creation of plugins that
// are an embedded component of the application. Embedded plugins built using // are an embedded component of the application. Embedded plugins built using
// this interface use the same Netscape Plugin API as DLL-based plugins. // this interface use the same Netscape Plugin API as DLL-based plugins.
// See https://developer.mozilla.org/En/Gecko_Plugin_API_Reference for complete // See https://developer.mozilla.org/En/Gecko_Plugin_API_Reference for complete
// documentation on how to use the Netscape Plugin API. // documentation on how to use the Netscape Plugin API.
// This structure describes a mime type entry for a plugin. // This structure describes a mime type entry for a plugin.
struct CefPluginMimeType { struct CefPluginMimeType {
// The actual mime type. // The actual mime type.
std::wstring mime_type; std::wstring mime_type;
// A list of all the file extensions for this mime type. // A list of all the file extensions for this mime type.
std::vector<std::wstring> file_extensions; std::vector<std::wstring> file_extensions;
// Description of the mime type. // Description of the mime type.
std::wstring description; std::wstring description;
}; };
// This structure provides attribute information and entry point functions for // This structure provides attribute information and entry point functions for
// a plugin. // a plugin.
struct CefPluginInfo { struct CefPluginInfo {
// The unique name that identifies the plugin. // The unique name that identifies the plugin.
std::wstring unique_name; std::wstring unique_name;
// The friendly display name of the plugin. // The friendly display name of the plugin.
std::wstring display_name; std::wstring display_name;
// The version string of the plugin. // The version string of the plugin.
std::wstring version; std::wstring version;
// A description of the plugin. // A description of the plugin.
std::wstring description; std::wstring description;
// A list of all the mime types that this plugin supports. // A list of all the mime types that this plugin supports.
std::vector<CefPluginMimeType> mime_types; std::vector<CefPluginMimeType> mime_types;
// Entry point function pointers. // Entry point function pointers.
NP_GetEntryPointsFunc np_getentrypoints; NP_GetEntryPointsFunc np_getentrypoints;
NP_InitializeFunc np_initialize; NP_InitializeFunc np_initialize;
NP_ShutdownFunc np_shutdown; NP_ShutdownFunc np_shutdown;
}; };
// Register a plugin with the system. // Register a plugin with the system.
bool CefRegisterPlugin(const struct CefPluginInfo& plugin_info); bool CefRegisterPlugin(const struct CefPluginInfo& plugin_info);
#endif // _CEF_PLUGIN_H #endif // _CEF_PLUGIN_H

View File

@ -1,90 +1,90 @@
// Copyright (c) 2009 Marshall A. Greenblatt. All rights reserved. // Copyright (c) 2009 Marshall A. Greenblatt. All rights reserved.
// //
// Redistribution and use in source and binary forms, with or without // Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are // modification, are permitted provided that the following conditions are
// met: // met:
// //
// * Redistributions of source code must retain the above copyright // * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer. // notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above // * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer // copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the // in the documentation and/or other materials provided with the
// distribution. // distribution.
// * Neither the name of Google Inc. nor the name Chromium Embedded // * Neither the name of Google Inc. nor the name Chromium Embedded
// Framework nor the names of its contributors may be used to endorse // Framework nor the names of its contributors may be used to endorse
// or promote products derived from this software without specific prior // or promote products derived from this software without specific prior
// written permission. // written permission.
// //
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef _CEF_PLUGIN_CAPI_H #ifndef _CEF_PLUGIN_CAPI_H
#define _CEF_PLUGIN_CAPI_H #define _CEF_PLUGIN_CAPI_H
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
#include "cef_export.h" #include "cef_export.h"
#include "third_party/npapi/bindings/npapi.h" #include "third_party/npapi/bindings/npapi.h"
#include "third_party/npapi/bindings/nphostapi.h" #include "third_party/npapi/bindings/nphostapi.h"
// Netscape plugins are normally built at separate DLLs that are loaded by the // Netscape plugins are normally built at separate DLLs that are loaded by the
// browser when needed. This interface supports the creation of plugins that // browser when needed. This interface supports the creation of plugins that
// are an embedded component of the application. Embedded plugins built using // are an embedded component of the application. Embedded plugins built using
// this interface use the same Netscape Plugin API as DLL-based plugins. // this interface use the same Netscape Plugin API as DLL-based plugins.
// See https://developer.mozilla.org/En/Gecko_Plugin_API_Reference for complete // See https://developer.mozilla.org/En/Gecko_Plugin_API_Reference for complete
// documentation on how to use the Netscape Plugin API. // documentation on how to use the Netscape Plugin API.
// This structure provides attribute information and entry point functions for // This structure provides attribute information and entry point functions for
// a plugin. // a plugin.
typedef struct _cef_plugin_info_t { typedef struct _cef_plugin_info_t {
// The unique name that identifies the plugin. // The unique name that identifies the plugin.
const wchar_t* unique_name; const wchar_t* unique_name;
// The friendly display name of the plugin. // The friendly display name of the plugin.
const wchar_t* display_name; const wchar_t* display_name;
// The version string of the plugin. // The version string of the plugin.
const wchar_t* version; const wchar_t* version;
// A description of the plugin. // A description of the plugin.
const wchar_t* description; const wchar_t* description;
// A pipe (|) delimited list of mime type values that the plugin supports. // A pipe (|) delimited list of mime type values that the plugin supports.
const wchar_t* mime_types; const wchar_t* mime_types;
// A pipe (|) delimited list of extension values. Each value is associated // A pipe (|) delimited list of extension values. Each value is associated
// with the mime type value at the same position. Multiple file extensions // with the mime type value at the same position. Multiple file extensions
// for the same mime type may be delimited with commas (,). // for the same mime type may be delimited with commas (,).
const wchar_t* file_extensions; const wchar_t* file_extensions;
// A pipe (|) delimited list of description values. Each value is associated // A pipe (|) delimited list of description values. Each value is associated
// with the mime type value at the same position. // with the mime type value at the same position.
const wchar_t* type_descriptions; const wchar_t* type_descriptions;
// Entry point function pointers. // Entry point function pointers.
NP_GetEntryPointsFunc np_getentrypoints; NP_GetEntryPointsFunc np_getentrypoints;
NP_InitializeFunc np_initialize; NP_InitializeFunc np_initialize;
NP_ShutdownFunc np_shutdown; NP_ShutdownFunc np_shutdown;
} cef_plugin_info_t; } cef_plugin_info_t;
// Register a plugin with the system. Returns true (1) on success. // Register a plugin with the system. Returns true (1) on success.
CEF_EXPORT int cef_register_plugin(const cef_plugin_info_t* plugin_info); CEF_EXPORT int cef_register_plugin(const cef_plugin_info_t* plugin_info);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#endif // _CEF_PLUGIN_CAPI_H #endif // _CEF_PLUGIN_CAPI_H

View File

@ -1,193 +1,193 @@
// Copyright (c) 2008 Marshall A. Greenblatt. Portions Copyright (c) // Copyright (c) 2008 Marshall A. Greenblatt. Portions Copyright (c)
// 2006-2008 Google Inc. All rights reserved. // 2006-2008 Google Inc. All rights reserved.
// //
// Redistribution and use in source and binary forms, with or without // Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are // modification, are permitted provided that the following conditions are
// met: // met:
// //
// * Redistributions of source code must retain the above copyright // * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer. // notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above // * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer // copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the // in the documentation and/or other materials provided with the
// distribution. // distribution.
// * Neither the name of Google Inc. nor the name Chromium Embedded // * Neither the name of Google Inc. nor the name Chromium Embedded
// Framework nor the names of its contributors may be used to endorse // Framework nor the names of its contributors may be used to endorse
// or promote products derived from this software without specific prior // or promote products derived from this software without specific prior
// written permission. // written permission.
// //
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef _CEF_PTR_H #ifndef _CEF_PTR_H
#define _CEF_PTR_H #define _CEF_PTR_H
// Smart pointer implementation borrowed from base/ref_counted.h // Smart pointer implementation borrowed from base/ref_counted.h
// //
// A smart pointer class for reference counted objects. Use this class instead // A smart pointer class for reference counted objects. Use this class instead
// of calling AddRef and Release manually on a reference counted object to // of calling AddRef and Release manually on a reference counted object to
// avoid common memory leaks caused by forgetting to Release an object // avoid common memory leaks caused by forgetting to Release an object
// reference. Sample usage: // reference. Sample usage:
// //
// class MyFoo : public CefBase { // class MyFoo : public CefBase {
// ... // ...
// }; // };
// //
// void some_function() { // void some_function() {
// // The MyFoo object that |foo| represents starts with a single // // The MyFoo object that |foo| represents starts with a single
// // reference. // // reference.
// CefRefPtr<MyFoo> foo = new MyFoo(); // CefRefPtr<MyFoo> foo = new MyFoo();
// foo->Method(param); // foo->Method(param);
// // |foo| is released when this function returns // // |foo| is released when this function returns
// } // }
// //
// void some_other_function() { // void some_other_function() {
// CefRefPtr<MyFoo> foo = new MyFoo(); // CefRefPtr<MyFoo> foo = new MyFoo();
// ... // ...
// foo = NULL; // explicitly releases |foo| // foo = NULL; // explicitly releases |foo|
// ... // ...
// if (foo) // if (foo)
// foo->Method(param); // foo->Method(param);
// } // }
// //
// The above examples show how CefRefPtr<T> acts like a pointer to T. // The above examples show how CefRefPtr<T> acts like a pointer to T.
// Given two CefRefPtr<T> classes, it is also possible to exchange // Given two CefRefPtr<T> classes, it is also possible to exchange
// references between the two objects, like so: // references between the two objects, like so:
// //
// { // {
// CefRefPtr<MyFoo> a = new MyFoo(); // CefRefPtr<MyFoo> a = new MyFoo();
// CefRefPtr<MyFoo> b; // CefRefPtr<MyFoo> b;
// //
// b.swap(a); // b.swap(a);
// // now, |b| references the MyFoo object, and |a| references NULL. // // now, |b| references the MyFoo object, and |a| references NULL.
// } // }
// //
// To make both |a| and |b| in the above example reference the same MyFoo // To make both |a| and |b| in the above example reference the same MyFoo
// object, simply use the assignment operator: // object, simply use the assignment operator:
// //
// { // {
// CefRefPtr<MyFoo> a = new MyFoo(); // CefRefPtr<MyFoo> a = new MyFoo();
// CefRefPtr<MyFoo> b; // CefRefPtr<MyFoo> b;
// //
// b = a; // b = a;
// // now, |a| and |b| each own a reference to the same MyFoo object. // // now, |a| and |b| each own a reference to the same MyFoo object.
// // the reference count of the underlying MyFoo object will be 2. // // the reference count of the underlying MyFoo object will be 2.
// } // }
// //
// Reference counted objects can also be passed as function parameters and // Reference counted objects can also be passed as function parameters and
// used as function return values: // used as function return values:
// //
// void some_func_with_param(CefRefPtr<MyFoo> param) { // void some_func_with_param(CefRefPtr<MyFoo> param) {
// // A reference is added to the MyFoo object that |param| represents // // A reference is added to the MyFoo object that |param| represents
// // during the scope of some_func_with_param() and released when // // during the scope of some_func_with_param() and released when
// // some_func_with_param() goes out of scope. // // some_func_with_param() goes out of scope.
// } // }
// //
// CefRefPtr<MyFoo> some_func_with_retval() { // CefRefPtr<MyFoo> some_func_with_retval() {
// // The MyFoo object that |foox| represents starts with a single // // The MyFoo object that |foox| represents starts with a single
// // reference. // // reference.
// CefRefPtr<MyFoo> foox = new MyFoo(); // CefRefPtr<MyFoo> foox = new MyFoo();
// //
// // Creating the return value adds an additional reference. // // Creating the return value adds an additional reference.
// return foox; // return foox;
// //
// // When some_func_with_retval() goes out of scope the original |foox| // // When some_func_with_retval() goes out of scope the original |foox|
// // reference is released. // // reference is released.
// } // }
// //
// void and_another_function() { // void and_another_function() {
// CefRefPtr<MyFoo> foo = new MyFoo(); // CefRefPtr<MyFoo> foo = new MyFoo();
// //
// // pass |foo| as a parameter. // // pass |foo| as a parameter.
// some_function(foo); // some_function(foo);
// //
// CefRefPtr<MyFoo> foo2 = some_func_with_retval(); // CefRefPtr<MyFoo> foo2 = some_func_with_retval();
// // Now, since we kept a reference to the some_func_with_retval() return // // Now, since we kept a reference to the some_func_with_retval() return
// // value, |foo2| is the only class pointing to the MyFoo object created // // value, |foo2| is the only class pointing to the MyFoo object created
// in some_func_with_retval(), and it has a reference count of 1. // in some_func_with_retval(), and it has a reference count of 1.
// //
// some_func_with_retval(); // some_func_with_retval();
// // Now, since we didn't keep a reference to the some_func_with_retval() // // Now, since we didn't keep a reference to the some_func_with_retval()
// // return value, the MyFoo object created in some_func_with_retval() // // return value, the MyFoo object created in some_func_with_retval()
// // will automatically be released. // // will automatically be released.
// } // }
// //
// And in standard containers: // And in standard containers:
// //
// { // {
// // Create a vector that holds MyFoo objects. // // Create a vector that holds MyFoo objects.
// std::vector<CefRefPtr<MyFoo> > MyFooVec; // std::vector<CefRefPtr<MyFoo> > MyFooVec;
// //
// // The MyFoo object that |foo| represents starts with a single // // The MyFoo object that |foo| represents starts with a single
// // reference. // // reference.
// CefRefPtr<MyFoo> foo = new MyFoo(); // CefRefPtr<MyFoo> foo = new MyFoo();
// //
// // When the MyFoo object is added to |MyFooVec| the reference count // // When the MyFoo object is added to |MyFooVec| the reference count
// // is increased to 2. // // is increased to 2.
// MyFooVec.push_back(foo); // MyFooVec.push_back(foo);
// } // }
// //
template <class T> template <class T>
class CefRefPtr { class CefRefPtr {
public: public:
CefRefPtr() : ptr_(NULL) { CefRefPtr() : ptr_(NULL) {
} }
CefRefPtr(T* p) : ptr_(p) { CefRefPtr(T* p) : ptr_(p) {
if (ptr_) if (ptr_)
ptr_->AddRef(); ptr_->AddRef();
} }
CefRefPtr(const CefRefPtr<T>& r) : ptr_(r.ptr_) { CefRefPtr(const CefRefPtr<T>& r) : ptr_(r.ptr_) {
if (ptr_) if (ptr_)
ptr_->AddRef(); ptr_->AddRef();
} }
~CefRefPtr() { ~CefRefPtr() {
if (ptr_) if (ptr_)
ptr_->Release(); ptr_->Release();
} }
T* get() const { return ptr_; } T* get() const { return ptr_; }
operator T*() const { return ptr_; } operator T*() const { return ptr_; }
T* operator->() const { return ptr_; } T* operator->() const { return ptr_; }
CefRefPtr<T>& operator=(T* p) { CefRefPtr<T>& operator=(T* p) {
// AddRef first so that self assignment should work // AddRef first so that self assignment should work
if (p) if (p)
p->AddRef(); p->AddRef();
if (ptr_ ) if (ptr_ )
ptr_ ->Release(); ptr_ ->Release();
ptr_ = p; ptr_ = p;
return *this; return *this;
} }
CefRefPtr<T>& operator=(const CefRefPtr<T>& r) { CefRefPtr<T>& operator=(const CefRefPtr<T>& r) {
return *this = r.ptr_; return *this = r.ptr_;
} }
void swap(T** pp) { void swap(T** pp) {
T* p = ptr_; T* p = ptr_;
ptr_ = *pp; ptr_ = *pp;
*pp = p; *pp = p;
} }
void swap(CefRefPtr<T>& r) { void swap(CefRefPtr<T>& r) {
swap(&r.ptr_); swap(&r.ptr_);
} }
private: private:
T* ptr_; T* ptr_;
}; };
#endif // _CEF_PTR_H #endif // _CEF_PTR_H

View File

@ -1,86 +1,86 @@
// Copyright (c) 2009 Marshall A. Greenblatt. All rights reserved. // Copyright (c) 2009 Marshall A. Greenblatt. All rights reserved.
// //
// Redistribution and use in source and binary forms, with or without // Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are // modification, are permitted provided that the following conditions are
// met: // met:
// //
// * Redistributions of source code must retain the above copyright // * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer. // notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above // * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer // copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the // in the documentation and/or other materials provided with the
// distribution. // distribution.
// * Neither the name of Google Inc. nor the name Chromium Embedded // * Neither the name of Google Inc. nor the name Chromium Embedded
// Framework nor the names of its contributors may be used to endorse // Framework nor the names of its contributors may be used to endorse
// or promote products derived from this software without specific prior // or promote products derived from this software without specific prior
// written permission. // written permission.
// //
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef _CEF_STRING_H #ifndef _CEF_STRING_H
#define _CEF_STRING_H #define _CEF_STRING_H
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
#include "cef_export.h" #include "cef_export.h"
#include <wchar.h> #include <wchar.h>
// CEF strings are NUL-terminated wide character strings prefixed with a size // CEF strings are NUL-terminated wide character strings prefixed with a size
// value, similar to the Microsoft BSTR type. Use the below API functions for // value, similar to the Microsoft BSTR type. Use the below API functions for
// allocating, managing and freeing CEF strings. // allocating, managing and freeing CEF strings.
typedef wchar_t* cef_string_t; typedef wchar_t* cef_string_t;
// Return the wide character length of the CEF string as allocated by // Return the wide character length of the CEF string as allocated by
// cef_string_alloc_len(). The returned value does not include the NUL // cef_string_alloc_len(). The returned value does not include the NUL
// terminating character. This length may differ from the string length // terminating character. This length may differ from the string length
// as returned by wcslen(). // as returned by wcslen().
CEF_EXPORT size_t cef_string_length(cef_string_t str); CEF_EXPORT size_t cef_string_length(cef_string_t str);
// Allocate and return a new CEF string that is a copy of |str|. If |str| is // Allocate and return a new CEF string that is a copy of |str|. If |str| is
// NULL or if allocation fails NULL will be returned. If |str| is of length // NULL or if allocation fails NULL will be returned. If |str| is of length
// 0 a valid empty CEF string will be returned. // 0 a valid empty CEF string will be returned.
CEF_EXPORT cef_string_t cef_string_alloc(const wchar_t* str); CEF_EXPORT cef_string_t cef_string_alloc(const wchar_t* str);
// Allocate and return a new CEF string that is a copy of |str|. |len| is the // Allocate and return a new CEF string that is a copy of |str|. |len| is the
// wide character length of the new CEF string not including the NUL // wide character length of the new CEF string not including the NUL
// terminating character. |str| will be copied without checking for a NUL // terminating character. |str| will be copied without checking for a NUL
// terminating character. If |str| is NULL or if allocation fails NULL will // terminating character. If |str| is NULL or if allocation fails NULL will
// be returned. If |str| is of length 0 a valid empty CEF string will be // be returned. If |str| is of length 0 a valid empty CEF string will be
// returned. // returned.
CEF_EXPORT cef_string_t cef_string_alloc_length(const wchar_t* str, CEF_EXPORT cef_string_t cef_string_alloc_length(const wchar_t* str,
size_t len); size_t len);
// Reallocate an existing CEF string. The contents of |oldstr| will be // Reallocate an existing CEF string. The contents of |oldstr| will be
// replaced with the contents of |newstr|; |newstr| may not be NULL. Returns 1 // replaced with the contents of |newstr|; |newstr| may not be NULL. Returns 1
// on success and 0 on failure. // on success and 0 on failure.
CEF_EXPORT int cef_string_realloc(cef_string_t* oldstr, const wchar_t* newstr); CEF_EXPORT int cef_string_realloc(cef_string_t* oldstr, const wchar_t* newstr);
// Reallocate an existing CEF string. If |newstr| is NULL the contents of // Reallocate an existing CEF string. If |newstr| is NULL the contents of
// |oldstr| will remain unchanged; otherwise, they will be replaced with the // |oldstr| will remain unchanged; otherwise, they will be replaced with the
// contents of |newstr|. |len| is the new wide character length of the string // contents of |newstr|. |len| is the new wide character length of the string
// not including the NUL terminating character. Returns 1 on success and 0 // not including the NUL terminating character. Returns 1 on success and 0
// on failure. // on failure.
CEF_EXPORT int cef_string_realloc_length(cef_string_t* oldstr, CEF_EXPORT int cef_string_realloc_length(cef_string_t* oldstr,
const wchar_t* newstr, const wchar_t* newstr,
size_t len); size_t len);
// Free a CEF string. If |str| is NULL this function does nothing. // Free a CEF string. If |str| is NULL this function does nothing.
CEF_EXPORT void cef_string_free(cef_string_t str); CEF_EXPORT void cef_string_free(cef_string_t str);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#endif // _CEF_STRING_H #endif // _CEF_STRING_H

View File

@ -1,67 +1,67 @@
// Copyright (c) 2009 Marshall A. Greenblatt. All rights reserved. // Copyright (c) 2009 Marshall A. Greenblatt. All rights reserved.
// //
// Redistribution and use in source and binary forms, with or without // Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are // modification, are permitted provided that the following conditions are
// met: // met:
// //
// * Redistributions of source code must retain the above copyright // * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer. // notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above // * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer // copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the // in the documentation and/or other materials provided with the
// distribution. // distribution.
// * Neither the name of Google Inc. nor the name Chromium Embedded // * Neither the name of Google Inc. nor the name Chromium Embedded
// Framework nor the names of its contributors may be used to endorse // Framework nor the names of its contributors may be used to endorse
// or promote products derived from this software without specific prior // or promote products derived from this software without specific prior
// written permission. // written permission.
// //
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef _CEF_STRING_LIST_H #ifndef _CEF_STRING_LIST_H
#define _CEF_STRING_LIST_H #define _CEF_STRING_LIST_H
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
#include "cef_export.h" #include "cef_export.h"
#include "cef_string.h" #include "cef_string.h"
#include <wchar.h> #include <wchar.h>
// CEF string maps are a set of key/value string pairs. // CEF string maps are a set of key/value string pairs.
typedef void* cef_string_list_t; typedef void* cef_string_list_t;
// Allocate a new string map. // Allocate a new string map.
CEF_EXPORT cef_string_list_t cef_string_list_alloc(); CEF_EXPORT cef_string_list_t cef_string_list_alloc();
// Return the number of elements in the string list. // Return the number of elements in the string list.
CEF_EXPORT int cef_string_list_size(cef_string_list_t list); CEF_EXPORT int cef_string_list_size(cef_string_list_t list);
// Return the value at the specified zero-based string list index. // Return the value at the specified zero-based string list index.
CEF_EXPORT cef_string_t cef_string_list_value(cef_string_list_t list, int index); CEF_EXPORT cef_string_t cef_string_list_value(cef_string_list_t list, int index);
// Append a new key/value pair at the end of the string list. // Append a new key/value pair at the end of the string list.
CEF_EXPORT void cef_string_list_append(cef_string_list_t list, const wchar_t* value); CEF_EXPORT void cef_string_list_append(cef_string_list_t list, const wchar_t* value);
// Clear the string list. // Clear the string list.
CEF_EXPORT void cef_string_list_clear(cef_string_list_t list); CEF_EXPORT void cef_string_list_clear(cef_string_list_t list);
// Free the string list. // Free the string list.
CEF_EXPORT void cef_string_list_free(cef_string_list_t list); CEF_EXPORT void cef_string_list_free(cef_string_list_t list);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#endif // _CEF_STRING_LIST_H #endif // _CEF_STRING_LIST_H

View File

@ -1,75 +1,75 @@
// Copyright (c) 2009 Marshall A. Greenblatt. All rights reserved. // Copyright (c) 2009 Marshall A. Greenblatt. All rights reserved.
// //
// Redistribution and use in source and binary forms, with or without // Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are // modification, are permitted provided that the following conditions are
// met: // met:
// //
// * Redistributions of source code must retain the above copyright // * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer. // notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above // * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer // copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the // in the documentation and/or other materials provided with the
// distribution. // distribution.
// * Neither the name of Google Inc. nor the name Chromium Embedded // * Neither the name of Google Inc. nor the name Chromium Embedded
// Framework nor the names of its contributors may be used to endorse // Framework nor the names of its contributors may be used to endorse
// or promote products derived from this software without specific prior // or promote products derived from this software without specific prior
// written permission. // written permission.
// //
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef _CEF_STRING_MAP_H #ifndef _CEF_STRING_MAP_H
#define _CEF_STRING_MAP_H #define _CEF_STRING_MAP_H
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
#include "cef_export.h" #include "cef_export.h"
#include "cef_string.h" #include "cef_string.h"
#include <wchar.h> #include <wchar.h>
// CEF string maps are a set of key/value string pairs. // CEF string maps are a set of key/value string pairs.
typedef void* cef_string_map_t; typedef void* cef_string_map_t;
// Allocate a new string map. // Allocate a new string map.
CEF_EXPORT cef_string_map_t cef_string_map_alloc(); CEF_EXPORT cef_string_map_t cef_string_map_alloc();
// Return the number of elements in the string map. // Return the number of elements in the string map.
CEF_EXPORT int cef_string_map_size(cef_string_map_t map); CEF_EXPORT int cef_string_map_size(cef_string_map_t map);
// Return the value assigned to the specified key. // Return the value assigned to the specified key.
CEF_EXPORT cef_string_t cef_string_map_find(cef_string_map_t map, CEF_EXPORT cef_string_t cef_string_map_find(cef_string_map_t map,
const wchar_t* key); const wchar_t* key);
// Return the key at the specified zero-based string map index. // Return the key at the specified zero-based string map index.
CEF_EXPORT cef_string_t cef_string_map_key(cef_string_map_t map, int index); CEF_EXPORT cef_string_t cef_string_map_key(cef_string_map_t map, int index);
// Return the value at the specified zero-based string map index. // Return the value at the specified zero-based string map index.
CEF_EXPORT cef_string_t cef_string_map_value(cef_string_map_t map, int index); CEF_EXPORT cef_string_t cef_string_map_value(cef_string_map_t map, int index);
// Append a new key/value pair at the end of the string map. // Append a new key/value pair at the end of the string map.
CEF_EXPORT void cef_string_map_append(cef_string_map_t map, const wchar_t* key, CEF_EXPORT void cef_string_map_append(cef_string_map_t map, const wchar_t* key,
const wchar_t* value); const wchar_t* value);
// Clear the string map. // Clear the string map.
CEF_EXPORT void cef_string_map_clear(cef_string_map_t map); CEF_EXPORT void cef_string_map_clear(cef_string_map_t map);
// Free the string map. // Free the string map.
CEF_EXPORT void cef_string_map_free(cef_string_map_t map); CEF_EXPORT void cef_string_map_free(cef_string_map_t map);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#endif // _CEF_STRING_MAP_H #endif // _CEF_STRING_MAP_H

View File

@ -1,297 +1,297 @@
// Copyright (c) 2009 Marshall A. Greenblatt. All rights reserved. // Copyright (c) 2009 Marshall A. Greenblatt. All rights reserved.
// //
// Redistribution and use in source and binary forms, with or without // Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are // modification, are permitted provided that the following conditions are
// met: // met:
// //
// * Redistributions of source code must retain the above copyright // * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer. // notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above // * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer // copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the // in the documentation and/or other materials provided with the
// distribution. // distribution.
// * Neither the name of Google Inc. nor the name Chromium Embedded // * Neither the name of Google Inc. nor the name Chromium Embedded
// Framework nor the names of its contributors may be used to endorse // Framework nor the names of its contributors may be used to endorse
// or promote products derived from this software without specific prior // or promote products derived from this software without specific prior
// written permission. // written permission.
// //
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef _CEF_TYPES_H #ifndef _CEF_TYPES_H
#define _CEF_TYPES_H #define _CEF_TYPES_H
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
// Bring in platform-specific definitions. // Bring in platform-specific definitions.
#ifdef _WIN32 #ifdef _WIN32
#include "cef_types_win.h" #include "cef_types_win.h"
#endif #endif
// Define handler return value types. Returning RV_HANDLED indicates // Define handler return value types. Returning RV_HANDLED indicates
// that the implementation completely handled the method and that no further // that the implementation completely handled the method and that no further
// processing is required. Returning RV_CONTINUE indicates that the // processing is required. Returning RV_CONTINUE indicates that the
// implementation did not handle the method and that the default handler // implementation did not handle the method and that the default handler
// should be called. // should be called.
enum cef_retval_t enum cef_retval_t
{ {
RV_HANDLED = 0, RV_HANDLED = 0,
RV_CONTINUE = 1, RV_CONTINUE = 1,
}; };
// Various browser navigation types supported by chrome. // Various browser navigation types supported by chrome.
enum cef_handler_navtype_t enum cef_handler_navtype_t
{ {
NAVTYPE_LINKCLICKED = 0, NAVTYPE_LINKCLICKED = 0,
NAVTYPE_FORMSUBMITTED, NAVTYPE_FORMSUBMITTED,
NAVTYPE_BACKFORWARD, NAVTYPE_BACKFORWARD,
NAVTYPE_RELOAD, NAVTYPE_RELOAD,
NAVTYPE_FORMRESUBMITTED, NAVTYPE_FORMRESUBMITTED,
NAVTYPE_OTHER, NAVTYPE_OTHER,
}; };
// Supported error code values. See net\base\net_error_list.h for complete // Supported error code values. See net\base\net_error_list.h for complete
// descriptions of the error codes. // descriptions of the error codes.
enum cef_handler_errorcode_t enum cef_handler_errorcode_t
{ {
ERR_FAILED = -2, ERR_FAILED = -2,
ERR_ABORTED = -3, ERR_ABORTED = -3,
ERR_INVALID_ARGUMENT = -4, ERR_INVALID_ARGUMENT = -4,
ERR_INVALID_HANDLE = -5, ERR_INVALID_HANDLE = -5,
ERR_FILE_NOT_FOUND = -6, ERR_FILE_NOT_FOUND = -6,
ERR_TIMED_OUT = -7, ERR_TIMED_OUT = -7,
ERR_FILE_TOO_BIG = -8, ERR_FILE_TOO_BIG = -8,
ERR_UNEXPECTED = -9, ERR_UNEXPECTED = -9,
ERR_ACCESS_DENIED = -10, ERR_ACCESS_DENIED = -10,
ERR_NOT_IMPLEMENTED = -11, ERR_NOT_IMPLEMENTED = -11,
ERR_CONNECTION_CLOSED = -100, ERR_CONNECTION_CLOSED = -100,
ERR_CONNECTION_RESET = -101, ERR_CONNECTION_RESET = -101,
ERR_CONNECTION_REFUSED = -102, ERR_CONNECTION_REFUSED = -102,
ERR_CONNECTION_ABORTED = -103, ERR_CONNECTION_ABORTED = -103,
ERR_CONNECTION_FAILED = -104, ERR_CONNECTION_FAILED = -104,
ERR_NAME_NOT_RESOLVED = -105, ERR_NAME_NOT_RESOLVED = -105,
ERR_INTERNET_DISCONNECTED = -106, ERR_INTERNET_DISCONNECTED = -106,
ERR_SSL_PROTOCOL_ERROR = -107, ERR_SSL_PROTOCOL_ERROR = -107,
ERR_ADDRESS_INVALID = -108, ERR_ADDRESS_INVALID = -108,
ERR_ADDRESS_UNREACHABLE = -109, ERR_ADDRESS_UNREACHABLE = -109,
ERR_SSL_CLIENT_AUTH_CERT_NEEDED = -110, ERR_SSL_CLIENT_AUTH_CERT_NEEDED = -110,
ERR_TUNNEL_CONNECTION_FAILED = -111, ERR_TUNNEL_CONNECTION_FAILED = -111,
ERR_NO_SSL_VERSIONS_ENABLED = -112, ERR_NO_SSL_VERSIONS_ENABLED = -112,
ERR_SSL_VERSION_OR_CIPHER_MISMATCH = -113, ERR_SSL_VERSION_OR_CIPHER_MISMATCH = -113,
ERR_SSL_RENEGOTIATION_REQUESTED = -114, ERR_SSL_RENEGOTIATION_REQUESTED = -114,
ERR_CERT_COMMON_NAME_INVALID = -200, ERR_CERT_COMMON_NAME_INVALID = -200,
ERR_CERT_DATE_INVALID = -201, ERR_CERT_DATE_INVALID = -201,
ERR_CERT_AUTHORITY_INVALID = -202, ERR_CERT_AUTHORITY_INVALID = -202,
ERR_CERT_CONTAINS_ERRORS = -203, ERR_CERT_CONTAINS_ERRORS = -203,
ERR_CERT_NO_REVOCATION_MECHANISM = -204, ERR_CERT_NO_REVOCATION_MECHANISM = -204,
ERR_CERT_UNABLE_TO_CHECK_REVOCATION = -205, ERR_CERT_UNABLE_TO_CHECK_REVOCATION = -205,
ERR_CERT_REVOKED = -206, ERR_CERT_REVOKED = -206,
ERR_CERT_INVALID = -207, ERR_CERT_INVALID = -207,
ERR_CERT_END = -208, ERR_CERT_END = -208,
ERR_INVALID_URL = -300, ERR_INVALID_URL = -300,
ERR_DISALLOWED_URL_SCHEME = -301, ERR_DISALLOWED_URL_SCHEME = -301,
ERR_UNKNOWN_URL_SCHEME = -302, ERR_UNKNOWN_URL_SCHEME = -302,
ERR_TOO_MANY_REDIRECTS = -310, ERR_TOO_MANY_REDIRECTS = -310,
ERR_UNSAFE_REDIRECT = -311, ERR_UNSAFE_REDIRECT = -311,
ERR_UNSAFE_PORT = -312, ERR_UNSAFE_PORT = -312,
ERR_INVALID_RESPONSE = -320, ERR_INVALID_RESPONSE = -320,
ERR_INVALID_CHUNKED_ENCODING = -321, ERR_INVALID_CHUNKED_ENCODING = -321,
ERR_METHOD_NOT_SUPPORTED = -322, ERR_METHOD_NOT_SUPPORTED = -322,
ERR_UNEXPECTED_PROXY_AUTH = -323, ERR_UNEXPECTED_PROXY_AUTH = -323,
ERR_EMPTY_RESPONSE = -324, ERR_EMPTY_RESPONSE = -324,
ERR_RESPONSE_HEADERS_TOO_BIG = -325, ERR_RESPONSE_HEADERS_TOO_BIG = -325,
ERR_CACHE_MISS = -400, ERR_CACHE_MISS = -400,
ERR_INSECURE_RESPONSE = -501, ERR_INSECURE_RESPONSE = -501,
}; };
// Structure representing menu information. // Structure representing menu information.
typedef struct _cef_handler_menuinfo_t typedef struct _cef_handler_menuinfo_t
{ {
int typeFlags; int typeFlags;
int x; int x;
int y; int y;
const wchar_t* linkUrl; const wchar_t* linkUrl;
const wchar_t* imageUrl; const wchar_t* imageUrl;
const wchar_t* pageUrl; const wchar_t* pageUrl;
const wchar_t* frameUrl; const wchar_t* frameUrl;
const wchar_t* selectionText; const wchar_t* selectionText;
const wchar_t* misspelledWord; const wchar_t* misspelledWord;
int editFlags; int editFlags;
const wchar_t* securityInfo; const wchar_t* securityInfo;
} cef_handler_menuinfo_t; } cef_handler_menuinfo_t;
// The cef_handler_menuinfo_t typeFlags value will be a combination of the // The cef_handler_menuinfo_t typeFlags value will be a combination of the
// following values. // following values.
enum cef_handler_menutypebits_t enum cef_handler_menutypebits_t
{ {
// No node is selected // No node is selected
MENUTYPE_NONE = 0x0, MENUTYPE_NONE = 0x0,
// The top page is selected // The top page is selected
MENUTYPE_PAGE = 0x1, MENUTYPE_PAGE = 0x1,
// A subframe page is selected // A subframe page is selected
MENUTYPE_FRAME = 0x2, MENUTYPE_FRAME = 0x2,
// A link is selected // A link is selected
MENUTYPE_LINK = 0x4, MENUTYPE_LINK = 0x4,
// An image is selected // An image is selected
MENUTYPE_IMAGE = 0x8, MENUTYPE_IMAGE = 0x8,
// There is a textual or mixed selection that is selected // There is a textual or mixed selection that is selected
MENUTYPE_SELECTION = 0x10, MENUTYPE_SELECTION = 0x10,
// An editable element is selected // An editable element is selected
MENUTYPE_EDITABLE = 0x20, MENUTYPE_EDITABLE = 0x20,
// A misspelled word is selected // A misspelled word is selected
MENUTYPE_MISSPELLED_WORD = 0x40, MENUTYPE_MISSPELLED_WORD = 0x40,
// A video node is selected // A video node is selected
MENUTYPE_VIDEO = 0x80, MENUTYPE_VIDEO = 0x80,
// A video node is selected // A video node is selected
MENUTYPE_AUDIO = 0x100, MENUTYPE_AUDIO = 0x100,
}; };
// The cef_handler_menuinfo_t editFlags value will be a combination of the // The cef_handler_menuinfo_t editFlags value will be a combination of the
// following values. // following values.
enum cef_handler_menucapabilitybits_t enum cef_handler_menucapabilitybits_t
{ {
// Values from WebContextMenuData::EditFlags in WebContextMenuData.h // Values from WebContextMenuData::EditFlags in WebContextMenuData.h
MENU_CAN_DO_NONE = 0x0, MENU_CAN_DO_NONE = 0x0,
MENU_CAN_UNDO = 0x1, MENU_CAN_UNDO = 0x1,
MENU_CAN_REDO = 0x2, MENU_CAN_REDO = 0x2,
MENU_CAN_CUT = 0x4, MENU_CAN_CUT = 0x4,
MENU_CAN_COPY = 0x8, MENU_CAN_COPY = 0x8,
MENU_CAN_PASTE = 0x10, MENU_CAN_PASTE = 0x10,
MENU_CAN_DELETE = 0x20, MENU_CAN_DELETE = 0x20,
MENU_CAN_SELECT_ALL = 0x40, MENU_CAN_SELECT_ALL = 0x40,
MENU_CAN_TRANSLATE = 0x80, MENU_CAN_TRANSLATE = 0x80,
// Values unique to CEF // Values unique to CEF
MENU_CAN_GO_FORWARD = 0x10000000, MENU_CAN_GO_FORWARD = 0x10000000,
MENU_CAN_GO_BACK = 0x20000000, MENU_CAN_GO_BACK = 0x20000000,
}; };
// Supported menu ID values. // Supported menu ID values.
enum cef_handler_menuid_t enum cef_handler_menuid_t
{ {
MENU_ID_NAV_BACK = 10, MENU_ID_NAV_BACK = 10,
MENU_ID_NAV_FORWARD = 11, MENU_ID_NAV_FORWARD = 11,
MENU_ID_NAV_RELOAD = 12, MENU_ID_NAV_RELOAD = 12,
MENU_ID_NAV_RELOAD_NOCACHE = 13, MENU_ID_NAV_RELOAD_NOCACHE = 13,
MENU_ID_NAV_STOP = 14, MENU_ID_NAV_STOP = 14,
MENU_ID_UNDO = 20, MENU_ID_UNDO = 20,
MENU_ID_REDO = 21, MENU_ID_REDO = 21,
MENU_ID_CUT = 22, MENU_ID_CUT = 22,
MENU_ID_COPY = 23, MENU_ID_COPY = 23,
MENU_ID_PASTE = 24, MENU_ID_PASTE = 24,
MENU_ID_DELETE = 25, MENU_ID_DELETE = 25,
MENU_ID_SELECTALL = 26, MENU_ID_SELECTALL = 26,
MENU_ID_PRINT = 30, MENU_ID_PRINT = 30,
MENU_ID_VIEWSOURCE = 31, MENU_ID_VIEWSOURCE = 31,
}; };
// Post data elements may represent either bytes or files. // Post data elements may represent either bytes or files.
enum cef_postdataelement_type_t enum cef_postdataelement_type_t
{ {
PDE_TYPE_EMPTY = 0, PDE_TYPE_EMPTY = 0,
PDE_TYPE_BYTES, PDE_TYPE_BYTES,
PDE_TYPE_FILE, PDE_TYPE_FILE,
}; };
// Key event types. // Key event types.
enum cef_handler_keyevent_type_t enum cef_handler_keyevent_type_t
{ {
KEYEVENT_RAWKEYDOWN = 0, KEYEVENT_RAWKEYDOWN = 0,
KEYEVENT_KEYDOWN, KEYEVENT_KEYDOWN,
KEYEVENT_KEYUP, KEYEVENT_KEYUP,
KEYEVENT_CHAR KEYEVENT_CHAR
}; };
// Key event modifiers. // Key event modifiers.
enum cef_handler_keyevent_modifiers_t enum cef_handler_keyevent_modifiers_t
{ {
KEY_SHIFT = 1 << 0, KEY_SHIFT = 1 << 0,
KEY_CTRL = 1 << 1, KEY_CTRL = 1 << 1,
KEY_ALT = 1 << 2, KEY_ALT = 1 << 2,
KEY_META = 1 << 3 KEY_META = 1 << 3
}; };
// Structure representing a rectangle. // Structure representing a rectangle.
typedef struct _cef_rect_t typedef struct _cef_rect_t
{ {
int x; int x;
int y; int y;
int width; int width;
int height; int height;
} cef_rect_t; } cef_rect_t;
// Existing thread IDs. // Existing thread IDs.
enum cef_thread_id_t enum cef_thread_id_t
{ {
TID_UI = 0, TID_UI = 0,
TID_IO = 1, TID_IO = 1,
TID_FILE = 2, TID_FILE = 2,
}; };
// Paper type for printing. // Paper type for printing.
enum cef_paper_type_t enum cef_paper_type_t
{ {
PT_LETTER = 0, PT_LETTER = 0,
PT_LEGAL, PT_LEGAL,
PT_EXECUTIVE, PT_EXECUTIVE,
PT_A3, PT_A3,
PT_A4, PT_A4,
PT_CUSTOM PT_CUSTOM
}; };
// Paper metric information for printing. // Paper metric information for printing.
struct cef_paper_metrics struct cef_paper_metrics
{ {
enum cef_paper_type_t paper_type; enum cef_paper_type_t paper_type;
//Length and width needed if paper_type is custom_size //Length and width needed if paper_type is custom_size
//Units are in inches. //Units are in inches.
double length; double length;
double width; double width;
}; };
// Paper print margins. // Paper print margins.
struct cef_print_margins struct cef_print_margins
{ {
//Margin size in inches for left/right/top/bottom (this is content margins). //Margin size in inches for left/right/top/bottom (this is content margins).
double left; double left;
double right; double right;
double top; double top;
double bottom; double bottom;
//Margin size (top/bottom) in inches for header/footer. //Margin size (top/bottom) in inches for header/footer.
double header; double header;
double footer; double footer;
}; };
// Page orientation for printing // Page orientation for printing
enum cef_page_orientation enum cef_page_orientation
{ {
PORTRAIT = 0, PORTRAIT = 0,
LANDSCAPE LANDSCAPE
}; };
// Printing options. // Printing options.
typedef struct _cef_print_options_t typedef struct _cef_print_options_t
{ {
enum cef_page_orientation page_orientation; enum cef_page_orientation page_orientation;
struct cef_paper_metrics paper_metrics; struct cef_paper_metrics paper_metrics;
struct cef_print_margins paper_margins; struct cef_print_margins paper_margins;
} cef_print_options_t; } cef_print_options_t;
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#endif // _CEF_TYPES_H #endif // _CEF_TYPES_H

View File

@ -1,76 +1,76 @@
// Copyright (c) 2009 Marshall A. Greenblatt. All rights reserved. // Copyright (c) 2009 Marshall A. Greenblatt. All rights reserved.
// //
// Redistribution and use in source and binary forms, with or without // Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are // modification, are permitted provided that the following conditions are
// met: // met:
// //
// * Redistributions of source code must retain the above copyright // * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer. // notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above // * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer // copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the // in the documentation and/or other materials provided with the
// distribution. // distribution.
// * Neither the name of Google Inc. nor the name Chromium Embedded // * Neither the name of Google Inc. nor the name Chromium Embedded
// Framework nor the names of its contributors may be used to endorse // Framework nor the names of its contributors may be used to endorse
// or promote products derived from this software without specific prior // or promote products derived from this software without specific prior
// written permission. // written permission.
// //
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef _CEF_TYPES_WIN_H #ifndef _CEF_TYPES_WIN_H
#define _CEF_TYPES_WIN_H #define _CEF_TYPES_WIN_H
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
#ifdef _WIN32 #ifdef _WIN32
#include <windows.h> #include <windows.h>
#include "cef_string.h" #include "cef_string.h"
// Class representing window information. // Class representing window information.
typedef struct _cef_window_info_t typedef struct _cef_window_info_t
{ {
// Standard parameters required by CreateWindowEx() // Standard parameters required by CreateWindowEx()
DWORD m_dwExStyle; DWORD m_dwExStyle;
cef_string_t m_windowName; cef_string_t m_windowName;
DWORD m_dwStyle; DWORD m_dwStyle;
int m_x; int m_x;
int m_y; int m_y;
int m_nWidth; int m_nWidth;
int m_nHeight; int m_nHeight;
HWND m_hWndParent; HWND m_hWndParent;
HMENU m_hMenu; HMENU m_hMenu;
// Handle for the new browser window. // Handle for the new browser window.
HWND m_hWnd; HWND m_hWnd;
} cef_window_info_t; } cef_window_info_t;
// Class representing print context information. // Class representing print context information.
typedef struct _cef_print_info_t typedef struct _cef_print_info_t
{ {
HDC m_hDC; HDC m_hDC;
RECT m_Rect; RECT m_Rect;
double m_Scale; double m_Scale;
} cef_print_info_t; } cef_print_info_t;
// Window handle. // Window handle.
#define cef_window_handle_t HWND #define cef_window_handle_t HWND
#endif // _WIN32 #endif // _WIN32
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#endif // _CEF_TYPES_WIN_H #endif // _CEF_TYPES_WIN_H

View File

@ -1,209 +1,209 @@
// Copyright (c) 2008 Marshall A. Greenblatt. All rights reserved. // Copyright (c) 2008 Marshall A. Greenblatt. All rights reserved.
// //
// Redistribution and use in source and binary forms, with or without // Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are // modification, are permitted provided that the following conditions are
// met: // met:
// //
// * Redistributions of source code must retain the above copyright // * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer. // notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above // * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer // copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the // in the documentation and/or other materials provided with the
// distribution. // distribution.
// * Neither the name of Google Inc. nor the name Chromium Embedded // * Neither the name of Google Inc. nor the name Chromium Embedded
// Framework nor the names of its contributors may be used to endorse // Framework nor the names of its contributors may be used to endorse
// or promote products derived from this software without specific prior // or promote products derived from this software without specific prior
// written permission. // written permission.
// //
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef _CEF_WIN_H #ifndef _CEF_WIN_H
#define _CEF_WIN_H #define _CEF_WIN_H
#ifdef _WIN32 #ifdef _WIN32
#include <windows.h> #include <windows.h>
#include "cef_types_win.h" #include "cef_types_win.h"
// Atomic increment and decrement. // Atomic increment and decrement.
#define CefAtomicIncrement(p) InterlockedIncrement(p) #define CefAtomicIncrement(p) InterlockedIncrement(p)
#define CefAtomicDecrement(p) InterlockedDecrement(p) #define CefAtomicDecrement(p) InterlockedDecrement(p)
// Critical section wrapper. // Critical section wrapper.
class CefCriticalSection class CefCriticalSection
{ {
public: public:
CefCriticalSection() CefCriticalSection()
{ {
memset(&m_sec, 0, sizeof(CRITICAL_SECTION)); memset(&m_sec, 0, sizeof(CRITICAL_SECTION));
InitializeCriticalSection(&m_sec); InitializeCriticalSection(&m_sec);
} }
~CefCriticalSection() ~CefCriticalSection()
{ {
DeleteCriticalSection(&m_sec); DeleteCriticalSection(&m_sec);
} }
void Lock() void Lock()
{ {
EnterCriticalSection(&m_sec); EnterCriticalSection(&m_sec);
} }
void Unlock() void Unlock()
{ {
LeaveCriticalSection(&m_sec); LeaveCriticalSection(&m_sec);
} }
CRITICAL_SECTION m_sec; CRITICAL_SECTION m_sec;
}; };
// Class representing window information. // Class representing window information.
class CefWindowInfo : public cef_window_info_t class CefWindowInfo : public cef_window_info_t
{ {
public: public:
CefWindowInfo() CefWindowInfo()
{ {
Init(); Init();
} }
~CefWindowInfo() ~CefWindowInfo()
{ {
if(m_windowName) if(m_windowName)
cef_string_free(m_windowName); cef_string_free(m_windowName);
} }
CefWindowInfo(const CefWindowInfo& r) CefWindowInfo(const CefWindowInfo& r)
{ {
Init(); Init();
*this = r; *this = r;
} }
CefWindowInfo(const cef_window_info_t& r) CefWindowInfo(const cef_window_info_t& r)
{ {
Init(); Init();
*this = r; *this = r;
} }
void Init() void Init()
{ {
m_dwExStyle = 0; m_dwExStyle = 0;
m_windowName = NULL; m_windowName = NULL;
m_dwStyle = 0; m_dwStyle = 0;
m_x = 0; m_x = 0;
m_y = 0; m_y = 0;
m_nWidth = 0; m_nWidth = 0;
m_nHeight = 0; m_nHeight = 0;
m_hWndParent = NULL; m_hWndParent = NULL;
m_hMenu = 0; m_hMenu = 0;
m_hWnd = NULL; m_hWnd = NULL;
} }
CefWindowInfo& operator=(const CefWindowInfo& r) CefWindowInfo& operator=(const CefWindowInfo& r)
{ {
return operator=(static_cast<const cef_window_info_t&>(r)); return operator=(static_cast<const cef_window_info_t&>(r));
} }
CefWindowInfo& operator=(const cef_window_info_t& r) CefWindowInfo& operator=(const cef_window_info_t& r)
{ {
m_dwExStyle = r.m_dwExStyle; m_dwExStyle = r.m_dwExStyle;
if(m_windowName) if(m_windowName)
cef_string_free(m_windowName); cef_string_free(m_windowName);
if(r.m_windowName) if(r.m_windowName)
m_windowName = cef_string_alloc(r.m_windowName); m_windowName = cef_string_alloc(r.m_windowName);
else else
m_windowName = NULL; m_windowName = NULL;
m_dwStyle = r.m_dwStyle; m_dwStyle = r.m_dwStyle;
m_x = r.m_x; m_x = r.m_x;
m_y = r.m_y; m_y = r.m_y;
m_nWidth = r.m_nWidth; m_nWidth = r.m_nWidth;
m_nHeight = r.m_nHeight; m_nHeight = r.m_nHeight;
m_hWndParent = r.m_hWndParent; m_hWndParent = r.m_hWndParent;
m_hMenu = r.m_hMenu; m_hMenu = r.m_hMenu;
m_hWnd = r.m_hWnd; m_hWnd = r.m_hWnd;
return *this; return *this;
} }
void SetAsChild(HWND hWndParent, RECT windowRect) void SetAsChild(HWND hWndParent, RECT windowRect)
{ {
m_dwStyle = WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN m_dwStyle = WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN
| WS_CLIPSIBLINGS | WS_TABSTOP; | WS_CLIPSIBLINGS | WS_TABSTOP;
m_hWndParent = hWndParent; m_hWndParent = hWndParent;
m_x = windowRect.left; m_x = windowRect.left;
m_y = windowRect.top; m_y = windowRect.top;
m_nWidth = windowRect.right - windowRect.left; m_nWidth = windowRect.right - windowRect.left;
m_nHeight = windowRect.bottom - windowRect.top; m_nHeight = windowRect.bottom - windowRect.top;
} }
void SetAsPopup(HWND hWndParent, LPCWSTR windowName) void SetAsPopup(HWND hWndParent, LPCWSTR windowName)
{ {
m_dwStyle = WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN | WS_CLIPSIBLINGS; m_dwStyle = WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN | WS_CLIPSIBLINGS;
m_hWndParent = hWndParent; m_hWndParent = hWndParent;
m_x = CW_USEDEFAULT; m_x = CW_USEDEFAULT;
m_y = CW_USEDEFAULT; m_y = CW_USEDEFAULT;
m_nWidth = CW_USEDEFAULT; m_nWidth = CW_USEDEFAULT;
m_nHeight = CW_USEDEFAULT; m_nHeight = CW_USEDEFAULT;
if(m_windowName) if(m_windowName)
cef_string_free(m_windowName); cef_string_free(m_windowName);
if(windowName) if(windowName)
m_windowName = cef_string_alloc(windowName); m_windowName = cef_string_alloc(windowName);
else else
m_windowName = NULL; m_windowName = NULL;
} }
}; };
// Class representing print context information. // Class representing print context information.
class CefPrintInfo : public cef_print_info_t class CefPrintInfo : public cef_print_info_t
{ {
public: public:
CefPrintInfo() CefPrintInfo()
{ {
Init(); Init();
} }
~CefPrintInfo() ~CefPrintInfo()
{ {
} }
CefPrintInfo(const CefPrintInfo& r) CefPrintInfo(const CefPrintInfo& r)
{ {
Init(); Init();
*this = r; *this = r;
} }
CefPrintInfo(const cef_print_info_t& r) CefPrintInfo(const cef_print_info_t& r)
{ {
Init(); Init();
*this = r; *this = r;
} }
void Init() void Init()
{ {
m_hDC = NULL; m_hDC = NULL;
m_Rect.left = m_Rect.right = m_Rect.top = m_Rect.bottom = 0; m_Rect.left = m_Rect.right = m_Rect.top = m_Rect.bottom = 0;
m_Scale = 0; m_Scale = 0;
} }
CefPrintInfo& operator=(const CefPrintInfo& r) CefPrintInfo& operator=(const CefPrintInfo& r)
{ {
return operator=(static_cast<const cef_print_info_t&>(r)); return operator=(static_cast<const cef_print_info_t&>(r));
} }
CefPrintInfo& operator=(const cef_print_info_t& r) CefPrintInfo& operator=(const cef_print_info_t& r)
{ {
m_hDC = r.m_hDC; m_hDC = r.m_hDC;
m_Rect.left = r.m_Rect.left; m_Rect.left = r.m_Rect.left;
m_Rect.right = r.m_Rect.right; m_Rect.right = r.m_Rect.right;
m_Rect.top = r.m_Rect.top; m_Rect.top = r.m_Rect.top;
m_Rect.bottom = r.m_Rect.bottom; m_Rect.bottom = r.m_Rect.bottom;
m_Scale = r.m_Scale; m_Scale = r.m_Scale;
return *this; return *this;
} }
}; };
// Window handle. // Window handle.
#define CefWindowHandle cef_window_handle_t #define CefWindowHandle cef_window_handle_t
#endif // _WIN32 #endif // _WIN32
#endif // _CEF_WIN_H #endif // _CEF_WIN_H

View File

@ -1,168 +1,168 @@
// Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this
// source code is governed by a BSD-style license that can be found in the // source code is governed by a BSD-style license that can be found in the
// LICENSE file. // LICENSE file.
#ifndef _BROWSER_APPCACHE_SYSTEM_H #ifndef _BROWSER_APPCACHE_SYSTEM_H
#define _BROWSER_APPCACHE_SYSTEM_H #define _BROWSER_APPCACHE_SYSTEM_H
#include "base/file_path.h" #include "base/file_path.h"
#include "base/message_loop.h" #include "base/message_loop.h"
#include "base/thread.h" #include "base/thread.h"
#include "webkit/appcache/appcache_backend_impl.h" #include "webkit/appcache/appcache_backend_impl.h"
#include "webkit/appcache/appcache_frontend_impl.h" #include "webkit/appcache/appcache_frontend_impl.h"
#include "webkit/appcache/appcache_service.h" #include "webkit/appcache/appcache_service.h"
#include "webkit/appcache/appcache_thread.h" #include "webkit/appcache/appcache_thread.h"
#include "webkit/glue/resource_type.h" #include "webkit/glue/resource_type.h"
namespace WebKit { namespace WebKit {
class WebApplicationCacheHost; class WebApplicationCacheHost;
class WebApplicationCacheHostClient; class WebApplicationCacheHostClient;
} }
class BrowserBackendProxy; class BrowserBackendProxy;
class BrowserFrontendProxy; class BrowserFrontendProxy;
class URLRequest; class URLRequest;
class URLRequestContext; class URLRequestContext;
// A class that composes the constituent parts of an appcache system // A class that composes the constituent parts of an appcache system
// together for use in a single process with two relavant threads, // together for use in a single process with two relavant threads,
// a UI thread on which webkit runs and an IO thread on which URLRequests // a UI thread on which webkit runs and an IO thread on which URLRequests
// are handled. This class conspires with BrowserResourceLoaderBridge to // are handled. This class conspires with BrowserResourceLoaderBridge to
// retrieve resources from the appcache. // retrieve resources from the appcache.
class BrowserAppCacheSystem : public MessageLoop::DestructionObserver { class BrowserAppCacheSystem : public MessageLoop::DestructionObserver {
public: public:
// Should be instanced somewhere in main(). If not instanced, the public // Should be instanced somewhere in main(). If not instanced, the public
// static methods are all safe no-ops. // static methods are all safe no-ops.
BrowserAppCacheSystem(); BrowserAppCacheSystem();
virtual ~BrowserAppCacheSystem(); virtual ~BrowserAppCacheSystem();
// One-time main UI thread initialization. // One-time main UI thread initialization.
static void InitializeOnUIThread(const FilePath& cache_directory) { static void InitializeOnUIThread(const FilePath& cache_directory) {
if (instance_) if (instance_)
instance_->InitOnUIThread(cache_directory); instance_->InitOnUIThread(cache_directory);
} }
// Called by BrowserResourceLoaderBridge's IOThread class. // Called by BrowserResourceLoaderBridge's IOThread class.
// Per IO thread initialization. Only one IO thread can exist // Per IO thread initialization. Only one IO thread can exist
// at a time, but after IO thread termination a new one can be // at a time, but after IO thread termination a new one can be
// started on which this method should be called. The instance // started on which this method should be called. The instance
// is assumed to outlive the IO thread. // is assumed to outlive the IO thread.
static void InitializeOnIOThread(URLRequestContext* request_context) { static void InitializeOnIOThread(URLRequestContext* request_context) {
if (instance_) if (instance_)
instance_->InitOnIOThread(request_context); instance_->InitOnIOThread(request_context);
} }
// Called by TestShellWebKitInit to manufacture a 'host' for webcore. // Called by TestShellWebKitInit to manufacture a 'host' for webcore.
static WebKit::WebApplicationCacheHost* CreateApplicationCacheHost( static WebKit::WebApplicationCacheHost* CreateApplicationCacheHost(
WebKit::WebApplicationCacheHostClient* client) { WebKit::WebApplicationCacheHostClient* client) {
return instance_ ? instance_->CreateCacheHostForWebKit(client) : NULL; return instance_ ? instance_->CreateCacheHostForWebKit(client) : NULL;
} }
// Called by BrowserResourceLoaderBridge to hook into resource loads. // Called by BrowserResourceLoaderBridge to hook into resource loads.
static void SetExtraRequestInfo(URLRequest* request, static void SetExtraRequestInfo(URLRequest* request,
int host_id, int host_id,
ResourceType::Type resource_type) { ResourceType::Type resource_type) {
if (instance_) if (instance_)
instance_->SetExtraRequestBits(request, host_id, resource_type); instance_->SetExtraRequestBits(request, host_id, resource_type);
} }
// Called by BrowserResourceLoaderBridge extract extra response bits. // Called by BrowserResourceLoaderBridge extract extra response bits.
static void GetExtraResponseInfo(URLRequest* request, static void GetExtraResponseInfo(URLRequest* request,
int64* cache_id, int64* cache_id,
GURL* manifest_url) { GURL* manifest_url) {
if (instance_) if (instance_)
instance_->GetExtraResponseBits(request, cache_id, manifest_url); instance_->GetExtraResponseBits(request, cache_id, manifest_url);
} }
// Some unittests create their own IO and DB threads. // Some unittests create their own IO and DB threads.
enum AppCacheThreadID { enum AppCacheThreadID {
DB_THREAD_ID, DB_THREAD_ID,
IO_THREAD_ID, IO_THREAD_ID,
}; };
class ThreadProvider { class ThreadProvider {
public: public:
virtual ~ThreadProvider() {} virtual ~ThreadProvider() {}
virtual bool PostTask( virtual bool PostTask(
int id, int id,
const tracked_objects::Location& from_here, const tracked_objects::Location& from_here,
Task* task) = 0; Task* task) = 0;
virtual bool CurrentlyOn(int id) = 0; virtual bool CurrentlyOn(int id) = 0;
}; };
static void set_thread_provider(ThreadProvider* provider) { static void set_thread_provider(ThreadProvider* provider) {
DCHECK(instance_); DCHECK(instance_);
DCHECK(!provider || !instance_->thread_provider_); DCHECK(!provider || !instance_->thread_provider_);
instance_->thread_provider_ = provider; instance_->thread_provider_ = provider;
} }
static ThreadProvider* thread_provider() { static ThreadProvider* thread_provider() {
return instance_ ? instance_->thread_provider_ : NULL; return instance_ ? instance_->thread_provider_ : NULL;
} }
private: private:
friend class BrowserBackendProxy; friend class BrowserBackendProxy;
friend class BrowserFrontendProxy; friend class BrowserFrontendProxy;
friend class appcache::AppCacheThread; friend class appcache::AppCacheThread;
// Instance methods called by our static public methods // Instance methods called by our static public methods
void InitOnUIThread(const FilePath& cache_directory); void InitOnUIThread(const FilePath& cache_directory);
void InitOnIOThread(URLRequestContext* request_context); void InitOnIOThread(URLRequestContext* request_context);
WebKit::WebApplicationCacheHost* CreateCacheHostForWebKit( WebKit::WebApplicationCacheHost* CreateCacheHostForWebKit(
WebKit::WebApplicationCacheHostClient* client); WebKit::WebApplicationCacheHostClient* client);
void SetExtraRequestBits(URLRequest* request, void SetExtraRequestBits(URLRequest* request,
int host_id, int host_id,
ResourceType::Type resource_type); ResourceType::Type resource_type);
void GetExtraResponseBits(URLRequest* request, void GetExtraResponseBits(URLRequest* request,
int64* cache_id, int64* cache_id,
GURL* manifest_url); GURL* manifest_url);
// Helpers // Helpers
MessageLoop* io_message_loop() { return io_message_loop_; } MessageLoop* io_message_loop() { return io_message_loop_; }
MessageLoop* ui_message_loop() { return ui_message_loop_; } MessageLoop* ui_message_loop() { return ui_message_loop_; }
bool is_io_thread() { return MessageLoop::current() == io_message_loop_; } bool is_io_thread() { return MessageLoop::current() == io_message_loop_; }
bool is_ui_thread() { return MessageLoop::current() == ui_message_loop_; } bool is_ui_thread() { return MessageLoop::current() == ui_message_loop_; }
bool is_initialized() { bool is_initialized() {
return io_message_loop_ && is_initailized_on_ui_thread(); return io_message_loop_ && is_initailized_on_ui_thread();
} }
bool is_initailized_on_ui_thread() { bool is_initailized_on_ui_thread() {
return ui_message_loop_ ? true : false; return ui_message_loop_ ? true : false;
} }
static MessageLoop* GetMessageLoop(int id) { static MessageLoop* GetMessageLoop(int id) {
if (instance_) { if (instance_) {
if (id == IO_THREAD_ID) if (id == IO_THREAD_ID)
return instance_->io_message_loop_; return instance_->io_message_loop_;
if (id == DB_THREAD_ID) if (id == DB_THREAD_ID)
return instance_->db_thread_.message_loop(); return instance_->db_thread_.message_loop();
NOTREACHED() << "Invalid AppCacheThreadID value"; NOTREACHED() << "Invalid AppCacheThreadID value";
} }
return NULL; return NULL;
} }
// IOThread DestructionObserver // IOThread DestructionObserver
virtual void WillDestroyCurrentMessageLoop(); virtual void WillDestroyCurrentMessageLoop();
FilePath cache_directory_; FilePath cache_directory_;
MessageLoop* io_message_loop_; MessageLoop* io_message_loop_;
MessageLoop* ui_message_loop_; MessageLoop* ui_message_loop_;
scoped_refptr<BrowserBackendProxy> backend_proxy_; scoped_refptr<BrowserBackendProxy> backend_proxy_;
scoped_refptr<BrowserFrontendProxy> frontend_proxy_; scoped_refptr<BrowserFrontendProxy> frontend_proxy_;
appcache::AppCacheFrontendImpl frontend_impl_; appcache::AppCacheFrontendImpl frontend_impl_;
// Created and used only on the IO thread, these do // Created and used only on the IO thread, these do
// not survive IO thread termination. If a new IO thread // not survive IO thread termination. If a new IO thread
// is started new instances will be created. // is started new instances will be created.
appcache::AppCacheBackendImpl* backend_impl_; appcache::AppCacheBackendImpl* backend_impl_;
appcache::AppCacheService* service_; appcache::AppCacheService* service_;
// We start a thread for use as the DB thread. // We start a thread for use as the DB thread.
base::Thread db_thread_; base::Thread db_thread_;
// Some unittests create there own IO and DB threads. // Some unittests create there own IO and DB threads.
ThreadProvider* thread_provider_; ThreadProvider* thread_provider_;
// A low-tech singleton. // A low-tech singleton.
static BrowserAppCacheSystem* instance_; static BrowserAppCacheSystem* instance_;
}; };
#endif // _BROWSER_APPCACHE_SYSTEM_H #endif // _BROWSER_APPCACHE_SYSTEM_H

View File

@ -1,190 +1,190 @@
// Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this
// source code is governed by a BSD-style license that can be found in the // source code is governed by a BSD-style license that can be found in the
// LICENSE file. // LICENSE file.
#include "browser_database_system.h" #include "browser_database_system.h"
#include "base/auto_reset.h" #include "base/auto_reset.h"
#include "base/file_util.h" #include "base/file_util.h"
#include "base/message_loop.h" #include "base/message_loop.h"
#include "base/platform_thread.h" #include "base/platform_thread.h"
#include "base/process_util.h" #include "base/process_util.h"
#include "base/utf_string_conversions.h" #include "base/utf_string_conversions.h"
#include "third_party/sqlite/sqlite3.h" #include "third_party/sqlite/sqlite3.h"
#include "third_party/WebKit/WebKit/chromium/public/WebDatabase.h" #include "third_party/WebKit/WebKit/chromium/public/WebDatabase.h"
#include "third_party/WebKit/WebKit/chromium/public/WebString.h" #include "third_party/WebKit/WebKit/chromium/public/WebString.h"
#include "webkit/database/database_util.h" #include "webkit/database/database_util.h"
#include "webkit/database/vfs_backend.h" #include "webkit/database/vfs_backend.h"
using webkit_database::DatabaseTracker; using webkit_database::DatabaseTracker;
using webkit_database::DatabaseUtil; using webkit_database::DatabaseUtil;
using webkit_database::VfsBackend; using webkit_database::VfsBackend;
BrowserDatabaseSystem* BrowserDatabaseSystem::instance_ = NULL; BrowserDatabaseSystem* BrowserDatabaseSystem::instance_ = NULL;
BrowserDatabaseSystem* BrowserDatabaseSystem::GetInstance() { BrowserDatabaseSystem* BrowserDatabaseSystem::GetInstance() {
DCHECK(instance_); DCHECK(instance_);
return instance_; return instance_;
} }
BrowserDatabaseSystem::BrowserDatabaseSystem() BrowserDatabaseSystem::BrowserDatabaseSystem()
: waiting_for_dbs_to_close_(false) { : waiting_for_dbs_to_close_(false) {
temp_dir_.CreateUniqueTempDir(); temp_dir_.CreateUniqueTempDir();
db_tracker_ = new DatabaseTracker(temp_dir_.path(), false); db_tracker_ = new DatabaseTracker(temp_dir_.path(), false);
db_tracker_->AddObserver(this); db_tracker_->AddObserver(this);
DCHECK(!instance_); DCHECK(!instance_);
instance_ = this; instance_ = this;
} }
BrowserDatabaseSystem::~BrowserDatabaseSystem() { BrowserDatabaseSystem::~BrowserDatabaseSystem() {
db_tracker_->RemoveObserver(this); db_tracker_->RemoveObserver(this);
instance_ = NULL; instance_ = NULL;
} }
base::PlatformFile BrowserDatabaseSystem::OpenFile( base::PlatformFile BrowserDatabaseSystem::OpenFile(
const string16& vfs_file_name, int desired_flags) { const string16& vfs_file_name, int desired_flags) {
base::PlatformFile file_handle = base::kInvalidPlatformFileValue; base::PlatformFile file_handle = base::kInvalidPlatformFileValue;
FilePath file_name = GetFullFilePathForVfsFile(vfs_file_name); FilePath file_name = GetFullFilePathForVfsFile(vfs_file_name);
if (file_name.empty()) { if (file_name.empty()) {
VfsBackend::OpenTempFileInDirectory( VfsBackend::OpenTempFileInDirectory(
db_tracker_->DatabaseDirectory(), desired_flags, &file_handle); db_tracker_->DatabaseDirectory(), desired_flags, &file_handle);
} else { } else {
VfsBackend::OpenFile(file_name, desired_flags, &file_handle); VfsBackend::OpenFile(file_name, desired_flags, &file_handle);
} }
return file_handle; return file_handle;
} }
int BrowserDatabaseSystem::DeleteFile( int BrowserDatabaseSystem::DeleteFile(
const string16& vfs_file_name, bool sync_dir) { const string16& vfs_file_name, bool sync_dir) {
// We try to delete the file multiple times, because that's what the default // We try to delete the file multiple times, because that's what the default
// VFS does (apparently deleting a file can sometimes fail on Windows). // VFS does (apparently deleting a file can sometimes fail on Windows).
// We sleep for 10ms between retries for the same reason. // We sleep for 10ms between retries for the same reason.
const int kNumDeleteRetries = 3; const int kNumDeleteRetries = 3;
int num_retries = 0; int num_retries = 0;
int error_code = SQLITE_OK; int error_code = SQLITE_OK;
FilePath file_name = GetFullFilePathForVfsFile(vfs_file_name); FilePath file_name = GetFullFilePathForVfsFile(vfs_file_name);
do { do {
error_code = VfsBackend::DeleteFile(file_name, sync_dir); error_code = VfsBackend::DeleteFile(file_name, sync_dir);
} while ((++num_retries < kNumDeleteRetries) && } while ((++num_retries < kNumDeleteRetries) &&
(error_code == SQLITE_IOERR_DELETE) && (error_code == SQLITE_IOERR_DELETE) &&
(PlatformThread::Sleep(10), 1)); (PlatformThread::Sleep(10), 1));
return error_code; return error_code;
} }
long BrowserDatabaseSystem::GetFileAttributes(const string16& vfs_file_name) { long BrowserDatabaseSystem::GetFileAttributes(const string16& vfs_file_name) {
return VfsBackend::GetFileAttributes( return VfsBackend::GetFileAttributes(
GetFullFilePathForVfsFile(vfs_file_name)); GetFullFilePathForVfsFile(vfs_file_name));
} }
long long BrowserDatabaseSystem::GetFileSize(const string16& vfs_file_name) { long long BrowserDatabaseSystem::GetFileSize(const string16& vfs_file_name) {
return VfsBackend::GetFileSize(GetFullFilePathForVfsFile(vfs_file_name)); return VfsBackend::GetFileSize(GetFullFilePathForVfsFile(vfs_file_name));
} }
void BrowserDatabaseSystem::DatabaseOpened(const string16& origin_identifier, void BrowserDatabaseSystem::DatabaseOpened(const string16& origin_identifier,
const string16& database_name, const string16& database_name,
const string16& description, const string16& description,
int64 estimated_size) { int64 estimated_size) {
int64 database_size = 0; int64 database_size = 0;
int64 space_available = 0; int64 space_available = 0;
database_connections_.AddConnection(origin_identifier, database_name); database_connections_.AddConnection(origin_identifier, database_name);
db_tracker_->DatabaseOpened(origin_identifier, database_name, description, db_tracker_->DatabaseOpened(origin_identifier, database_name, description,
estimated_size, &database_size, &space_available); estimated_size, &database_size, &space_available);
SetFullFilePathsForVfsFile(origin_identifier, database_name); SetFullFilePathsForVfsFile(origin_identifier, database_name);
OnDatabaseSizeChanged(origin_identifier, database_name, OnDatabaseSizeChanged(origin_identifier, database_name,
database_size, space_available); database_size, space_available);
} }
void BrowserDatabaseSystem::DatabaseModified(const string16& origin_identifier, void BrowserDatabaseSystem::DatabaseModified(const string16& origin_identifier,
const string16& database_name) { const string16& database_name) {
DCHECK(database_connections_.IsDatabaseOpened( DCHECK(database_connections_.IsDatabaseOpened(
origin_identifier, database_name)); origin_identifier, database_name));
db_tracker_->DatabaseModified(origin_identifier, database_name); db_tracker_->DatabaseModified(origin_identifier, database_name);
} }
void BrowserDatabaseSystem::DatabaseClosed(const string16& origin_identifier, void BrowserDatabaseSystem::DatabaseClosed(const string16& origin_identifier,
const string16& database_name) { const string16& database_name) {
DCHECK(database_connections_.IsDatabaseOpened( DCHECK(database_connections_.IsDatabaseOpened(
origin_identifier, database_name)); origin_identifier, database_name));
db_tracker_->DatabaseClosed(origin_identifier, database_name); db_tracker_->DatabaseClosed(origin_identifier, database_name);
database_connections_.RemoveConnection(origin_identifier, database_name); database_connections_.RemoveConnection(origin_identifier, database_name);
if (waiting_for_dbs_to_close_ && database_connections_.IsEmpty()) if (waiting_for_dbs_to_close_ && database_connections_.IsEmpty())
MessageLoop::current()->PostTask(FROM_HERE, new MessageLoop::QuitTask()); MessageLoop::current()->PostTask(FROM_HERE, new MessageLoop::QuitTask());
} }
void BrowserDatabaseSystem::OnDatabaseSizeChanged( void BrowserDatabaseSystem::OnDatabaseSizeChanged(
const string16& origin_identifier, const string16& origin_identifier,
const string16& database_name, const string16& database_name,
int64 database_size, int64 database_size,
int64 space_available) { int64 space_available) {
if (database_connections_.IsOriginUsed(origin_identifier)) { if (database_connections_.IsOriginUsed(origin_identifier)) {
WebKit::WebDatabase::updateDatabaseSize( WebKit::WebDatabase::updateDatabaseSize(
origin_identifier, database_name, database_size, space_available); origin_identifier, database_name, database_size, space_available);
} }
} }
void BrowserDatabaseSystem::OnDatabaseScheduledForDeletion( void BrowserDatabaseSystem::OnDatabaseScheduledForDeletion(
const string16& origin_identifier, const string16& origin_identifier,
const string16& database_name) { const string16& database_name) {
WebKit::WebDatabase::closeDatabaseImmediately( WebKit::WebDatabase::closeDatabaseImmediately(
origin_identifier, database_name); origin_identifier, database_name);
} }
void BrowserDatabaseSystem::databaseOpened(const WebKit::WebDatabase& database) { void BrowserDatabaseSystem::databaseOpened(const WebKit::WebDatabase& database) {
DatabaseOpened(database.securityOrigin().databaseIdentifier(), DatabaseOpened(database.securityOrigin().databaseIdentifier(),
database.name(), database.displayName(), database.name(), database.displayName(),
database.estimatedSize()); database.estimatedSize());
} }
void BrowserDatabaseSystem::databaseModified( void BrowserDatabaseSystem::databaseModified(
const WebKit::WebDatabase& database) { const WebKit::WebDatabase& database) {
DatabaseModified(database.securityOrigin().databaseIdentifier(), DatabaseModified(database.securityOrigin().databaseIdentifier(),
database.name()); database.name());
} }
void BrowserDatabaseSystem::databaseClosed(const WebKit::WebDatabase& database) { void BrowserDatabaseSystem::databaseClosed(const WebKit::WebDatabase& database) {
DatabaseClosed(database.securityOrigin().databaseIdentifier(), DatabaseClosed(database.securityOrigin().databaseIdentifier(),
database.name()); database.name());
} }
void BrowserDatabaseSystem::ClearAllDatabases() { void BrowserDatabaseSystem::ClearAllDatabases() {
// Wait for all databases to be closed. // Wait for all databases to be closed.
if (!database_connections_.IsEmpty()) { if (!database_connections_.IsEmpty()) {
AutoReset<bool> waiting_for_dbs_auto_reset(&waiting_for_dbs_to_close_, true); AutoReset<bool> waiting_for_dbs_auto_reset(&waiting_for_dbs_to_close_, true);
MessageLoop::ScopedNestableTaskAllower nestable(MessageLoop::current()); MessageLoop::ScopedNestableTaskAllower nestable(MessageLoop::current());
MessageLoop::current()->Run(); MessageLoop::current()->Run();
} }
db_tracker_->CloseTrackerDatabaseAndClearCaches(); db_tracker_->CloseTrackerDatabaseAndClearCaches();
file_util::Delete(db_tracker_->DatabaseDirectory(), true); file_util::Delete(db_tracker_->DatabaseDirectory(), true);
file_names_.clear(); file_names_.clear();
} }
void BrowserDatabaseSystem::SetDatabaseQuota(int64 quota) { void BrowserDatabaseSystem::SetDatabaseQuota(int64 quota) {
db_tracker_->SetDefaultQuota(quota); db_tracker_->SetDefaultQuota(quota);
} }
void BrowserDatabaseSystem::SetFullFilePathsForVfsFile( void BrowserDatabaseSystem::SetFullFilePathsForVfsFile(
const string16& origin_identifier, const string16& origin_identifier,
const string16& database_name) { const string16& database_name) {
string16 vfs_file_name = origin_identifier + ASCIIToUTF16("/") + string16 vfs_file_name = origin_identifier + ASCIIToUTF16("/") +
database_name + ASCIIToUTF16("#"); database_name + ASCIIToUTF16("#");
FilePath file_name = FilePath file_name =
DatabaseUtil::GetFullFilePathForVfsFile(db_tracker_, vfs_file_name); DatabaseUtil::GetFullFilePathForVfsFile(db_tracker_, vfs_file_name);
AutoLock file_names_auto_lock(file_names_lock_); AutoLock file_names_auto_lock(file_names_lock_);
file_names_[vfs_file_name] = file_name; file_names_[vfs_file_name] = file_name;
file_names_[vfs_file_name + ASCIIToUTF16("-journal")] = file_names_[vfs_file_name + ASCIIToUTF16("-journal")] =
FilePath::FromWStringHack(file_name.ToWStringHack() + FilePath::FromWStringHack(file_name.ToWStringHack() +
ASCIIToWide("-journal")); ASCIIToWide("-journal"));
} }
FilePath BrowserDatabaseSystem::GetFullFilePathForVfsFile( FilePath BrowserDatabaseSystem::GetFullFilePathForVfsFile(
const string16& vfs_file_name) { const string16& vfs_file_name) {
AutoLock file_names_auto_lock(file_names_lock_); AutoLock file_names_auto_lock(file_names_lock_);
DCHECK(file_names_.find(vfs_file_name) != file_names_.end()); DCHECK(file_names_.find(vfs_file_name) != file_names_.end());
return file_names_[vfs_file_name]; return file_names_[vfs_file_name];
} }

View File

@ -1,84 +1,84 @@
// Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this
// source code is governed by a BSD-style license that can be found in the // source code is governed by a BSD-style license that can be found in the
// LICENSE file. // LICENSE file.
#ifndef _BROWSER_DATABASE_SYSTEM_H #ifndef _BROWSER_DATABASE_SYSTEM_H
#define _BROWSER_DATABASE_SYSTEM_H #define _BROWSER_DATABASE_SYSTEM_H
#include "base/file_path.h" #include "base/file_path.h"
#include "base/hash_tables.h" #include "base/hash_tables.h"
#include "base/lock.h" #include "base/lock.h"
#include "base/platform_file.h" #include "base/platform_file.h"
#include "base/ref_counted.h" #include "base/ref_counted.h"
#include "base/scoped_temp_dir.h" #include "base/scoped_temp_dir.h"
#include "base/string16.h" #include "base/string16.h"
#include "third_party/WebKit/WebKit/chromium/public/WebDatabaseObserver.h" #include "third_party/WebKit/WebKit/chromium/public/WebDatabaseObserver.h"
#include "webkit/database/database_connections.h" #include "webkit/database/database_connections.h"
#include "webkit/database/database_tracker.h" #include "webkit/database/database_tracker.h"
class BrowserDatabaseSystem : public webkit_database::DatabaseTracker::Observer, class BrowserDatabaseSystem : public webkit_database::DatabaseTracker::Observer,
public WebKit::WebDatabaseObserver { public WebKit::WebDatabaseObserver {
public: public:
static BrowserDatabaseSystem* GetInstance(); static BrowserDatabaseSystem* GetInstance();
BrowserDatabaseSystem(); BrowserDatabaseSystem();
~BrowserDatabaseSystem(); ~BrowserDatabaseSystem();
// VFS functions // VFS functions
base::PlatformFile OpenFile(const string16& vfs_file_name, int desired_flags); base::PlatformFile OpenFile(const string16& vfs_file_name, int desired_flags);
int DeleteFile(const string16& vfs_file_name, bool sync_dir); int DeleteFile(const string16& vfs_file_name, bool sync_dir);
long GetFileAttributes(const string16& vfs_file_name); long GetFileAttributes(const string16& vfs_file_name);
long long GetFileSize(const string16& vfs_file_name); long long GetFileSize(const string16& vfs_file_name);
// database tracker functions // database tracker functions
void DatabaseOpened(const string16& origin_identifier, void DatabaseOpened(const string16& origin_identifier,
const string16& database_name, const string16& database_name,
const string16& description, const string16& description,
int64 estimated_size); int64 estimated_size);
void DatabaseModified(const string16& origin_identifier, void DatabaseModified(const string16& origin_identifier,
const string16& database_name); const string16& database_name);
void DatabaseClosed(const string16& origin_identifier, void DatabaseClosed(const string16& origin_identifier,
const string16& database_name); const string16& database_name);
// DatabaseTracker::Observer implementation // DatabaseTracker::Observer implementation
virtual void OnDatabaseSizeChanged(const string16& origin_identifier, virtual void OnDatabaseSizeChanged(const string16& origin_identifier,
const string16& database_name, const string16& database_name,
int64 database_size, int64 database_size,
int64 space_available); int64 space_available);
virtual void OnDatabaseScheduledForDeletion(const string16& origin_identifier, virtual void OnDatabaseScheduledForDeletion(const string16& origin_identifier,
const string16& database_name); const string16& database_name);
// WebDatabaseObserver implementation // WebDatabaseObserver implementation
virtual void databaseOpened(const WebKit::WebDatabase& database); virtual void databaseOpened(const WebKit::WebDatabase& database);
virtual void databaseModified(const WebKit::WebDatabase& database); virtual void databaseModified(const WebKit::WebDatabase& database);
virtual void databaseClosed(const WebKit::WebDatabase& database); virtual void databaseClosed(const WebKit::WebDatabase& database);
void ClearAllDatabases(); void ClearAllDatabases();
void SetDatabaseQuota(int64 quota); void SetDatabaseQuota(int64 quota);
private: private:
// The calls that come from the database tracker run on the main thread. // The calls that come from the database tracker run on the main thread.
// Therefore, we can only call DatabaseUtil::GetFullFilePathForVfsFile() // Therefore, we can only call DatabaseUtil::GetFullFilePathForVfsFile()
// on the main thread. However, the VFS calls run on the DB thread and // on the main thread. However, the VFS calls run on the DB thread and
// they need to crack VFS file paths. To resolve this problem, we store // they need to crack VFS file paths. To resolve this problem, we store
// a map of vfs_file_names to file_paths. The map is updated on the main // a map of vfs_file_names to file_paths. The map is updated on the main
// thread on each DatabaseOpened() call that comes from the database // thread on each DatabaseOpened() call that comes from the database
// tracker, and is read on the DB thread by each VFS call. // tracker, and is read on the DB thread by each VFS call.
void SetFullFilePathsForVfsFile(const string16& origin_identifier, void SetFullFilePathsForVfsFile(const string16& origin_identifier,
const string16& database_name); const string16& database_name);
FilePath GetFullFilePathForVfsFile(const string16& vfs_file_name); FilePath GetFullFilePathForVfsFile(const string16& vfs_file_name);
static BrowserDatabaseSystem* instance_; static BrowserDatabaseSystem* instance_;
bool waiting_for_dbs_to_close_; bool waiting_for_dbs_to_close_;
ScopedTempDir temp_dir_; ScopedTempDir temp_dir_;
scoped_refptr<webkit_database::DatabaseTracker> db_tracker_; scoped_refptr<webkit_database::DatabaseTracker> db_tracker_;
Lock file_names_lock_; Lock file_names_lock_;
base::hash_map<string16, FilePath> file_names_; base::hash_map<string16, FilePath> file_names_;
webkit_database::DatabaseConnections database_connections_; webkit_database::DatabaseConnections database_connections_;
}; };
#endif // _BROWSER_DATABASE_SYSTEM_H #endif // _BROWSER_DATABASE_SYSTEM_H

View File

@ -1,42 +1,42 @@
// Copyright (c) 2008 The Chromium Embedded Framework Authors. // Copyright (c) 2008 The Chromium Embedded Framework Authors.
// Portions copyright (c) 2006-2008 The Chromium Authors. All rights reserved. // Portions copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "browser_drag_delegate.h" #include "browser_drag_delegate.h"
#include "third_party/WebKit/WebKit/chromium/public/WebPoint.h" #include "third_party/WebKit/WebKit/chromium/public/WebPoint.h"
#include "third_party/WebKit/WebKit/chromium/public/WebView.h" #include "third_party/WebKit/WebKit/chromium/public/WebView.h"
using WebKit::WebPoint; using WebKit::WebPoint;
using WebKit::WebView; using WebKit::WebView;
namespace { namespace {
void GetCursorPositions(HWND hwnd, gfx::Point* client, gfx::Point* screen) { void GetCursorPositions(HWND hwnd, gfx::Point* client, gfx::Point* screen) {
// GetCursorPos will fail if the input desktop isn't the current desktop. // GetCursorPos will fail if the input desktop isn't the current desktop.
// See http://b/1173534. (0,0) is wrong, but better than uninitialized. // See http://b/1173534. (0,0) is wrong, but better than uninitialized.
POINT pos; POINT pos;
if (!GetCursorPos(&pos)) { if (!GetCursorPos(&pos)) {
pos.x = 0; pos.x = 0;
pos.y = 0; pos.y = 0;
} }
*screen = gfx::Point(pos); *screen = gfx::Point(pos);
ScreenToClient(hwnd, &pos); ScreenToClient(hwnd, &pos);
*client = gfx::Point(pos); *client = gfx::Point(pos);
} }
} // anonymous namespace } // anonymous namespace
void BrowserDragDelegate::OnDragSourceCancel() { void BrowserDragDelegate::OnDragSourceCancel() {
OnDragSourceDrop(); OnDragSourceDrop();
} }
void BrowserDragDelegate::OnDragSourceDrop() { void BrowserDragDelegate::OnDragSourceDrop() {
gfx::Point client; gfx::Point client;
gfx::Point screen; gfx::Point screen;
GetCursorPositions(source_hwnd_, &client, &screen); GetCursorPositions(source_hwnd_, &client, &screen);
webview_->dragSourceEndedAt(client, screen, WebKit::WebDragOperationCopy); webview_->dragSourceEndedAt(client, screen, WebKit::WebDragOperationCopy);
// TODO(snej): Pass the real drag operation instead // TODO(snej): Pass the real drag operation instead
} }

View File

@ -1,39 +1,39 @@
// Copyright (c) 2008 The Chromium Embedded Framework Authors. // Copyright (c) 2008 The Chromium Embedded Framework Authors.
// Portions copyright (c) 2006-2008 The Chromium Authors. All rights reserved. // Portions copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// //
// A class that implements BaseDragSource for the test shell webview delegate. // A class that implements BaseDragSource for the test shell webview delegate.
#ifndef _BROWSER_DRAG_DELEGATE_H #ifndef _BROWSER_DRAG_DELEGATE_H
#define _BROWSER_DRAG_DELEGATE_H #define _BROWSER_DRAG_DELEGATE_H
#include "base/base_drag_source.h" #include "base/base_drag_source.h"
namespace WebKit { namespace WebKit {
class WebView; class WebView;
} }
class BrowserDragDelegate : public BaseDragSource { class BrowserDragDelegate : public BaseDragSource {
public: public:
BrowserDragDelegate(HWND source_hwnd, WebKit::WebView* webview) BrowserDragDelegate(HWND source_hwnd, WebKit::WebView* webview)
: BaseDragSource(), : BaseDragSource(),
source_hwnd_(source_hwnd), source_hwnd_(source_hwnd),
webview_(webview) { } webview_(webview) { }
protected: protected:
// BaseDragSource // BaseDragSource
virtual void OnDragSourceCancel(); virtual void OnDragSourceCancel();
virtual void OnDragSourceDrop(); virtual void OnDragSourceDrop();
virtual void OnDragSourceMove(); virtual void OnDragSourceMove();
private: private:
WebKit::WebView* webview_; WebKit::WebView* webview_;
// A HWND for the source we are associated with, used for translating // A HWND for the source we are associated with, used for translating
// mouse coordinates from screen to client coordinates. // mouse coordinates from screen to client coordinates.
HWND source_hwnd_; HWND source_hwnd_;
}; };
#endif // _BROWSER_DRAG_DELEGATE_H #endif // _BROWSER_DRAG_DELEGATE_H

View File

@ -1,71 +1,71 @@
// Copyright (c) 2008 The Chromium Embedded Framework Authors. // Copyright (c) 2008 The Chromium Embedded Framework Authors.
// Portions copyright (c) 2006-2008 The Chromium Authors. All rights reserved. // Portions copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "browser_drop_delegate.h" #include "browser_drop_delegate.h"
#include "third_party/WebKit/WebKit/chromium/public/WebDragData.h" #include "third_party/WebKit/WebKit/chromium/public/WebDragData.h"
#include "third_party/WebKit/WebKit/chromium/public/WebPoint.h" #include "third_party/WebKit/WebKit/chromium/public/WebPoint.h"
#include "third_party/WebKit/WebKit/chromium/public/WebView.h" #include "third_party/WebKit/WebKit/chromium/public/WebView.h"
#include "webkit/glue/webdropdata.h" #include "webkit/glue/webdropdata.h"
using WebKit::WebDragOperation; using WebKit::WebDragOperation;
using WebKit::WebDragOperationCopy; using WebKit::WebDragOperationCopy;
using WebKit::WebPoint; using WebKit::WebPoint;
using WebKit::WebView; using WebKit::WebView;
// BaseDropTarget methods ---------------------------------------------------- // BaseDropTarget methods ----------------------------------------------------
DWORD BrowserDropDelegate::OnDragEnter(IDataObject* data_object, DWORD BrowserDropDelegate::OnDragEnter(IDataObject* data_object,
DWORD key_state, DWORD key_state,
POINT cursor_position, POINT cursor_position,
DWORD effect) { DWORD effect) {
WebDropData drop_data; WebDropData drop_data;
WebDropData::PopulateWebDropData(data_object, &drop_data); WebDropData::PopulateWebDropData(data_object, &drop_data);
POINT client_pt = cursor_position; POINT client_pt = cursor_position;
ScreenToClient(GetHWND(), &client_pt); ScreenToClient(GetHWND(), &client_pt);
WebDragOperation op = webview_->dragTargetDragEnter( WebDragOperation op = webview_->dragTargetDragEnter(
drop_data.ToDragData(), drop_data.identity, drop_data.ToDragData(), drop_data.identity,
WebPoint(client_pt.x, client_pt.y), WebPoint(client_pt.x, client_pt.y),
WebPoint(cursor_position.x, cursor_position.y), WebPoint(cursor_position.x, cursor_position.y),
WebDragOperationCopy); WebDragOperationCopy);
// TODO(snej): Pass the real drag operation instead // TODO(snej): Pass the real drag operation instead
return op ? DROPEFFECT_COPY : DROPEFFECT_NONE; return op ? DROPEFFECT_COPY : DROPEFFECT_NONE;
// TODO(snej): Return the real drop effect constant matching 'op' // TODO(snej): Return the real drop effect constant matching 'op'
} }
DWORD BrowserDropDelegate::OnDragOver(IDataObject* data_object, DWORD BrowserDropDelegate::OnDragOver(IDataObject* data_object,
DWORD key_state, DWORD key_state,
POINT cursor_position, POINT cursor_position,
DWORD effect) { DWORD effect) {
POINT client_pt = cursor_position; POINT client_pt = cursor_position;
ScreenToClient(GetHWND(), &client_pt); ScreenToClient(GetHWND(), &client_pt);
WebDragOperation op = webview_->dragTargetDragOver( WebDragOperation op = webview_->dragTargetDragOver(
WebPoint(client_pt.x, client_pt.y), WebPoint(client_pt.x, client_pt.y),
WebPoint(cursor_position.x, cursor_position.y), WebPoint(cursor_position.x, cursor_position.y),
WebDragOperationCopy); WebDragOperationCopy);
// TODO(snej): Pass the real drag operation instead // TODO(snej): Pass the real drag operation instead
return op ? DROPEFFECT_COPY : DROPEFFECT_NONE; return op ? DROPEFFECT_COPY : DROPEFFECT_NONE;
// TODO(snej): Return the real drop effect constant matching 'op' // TODO(snej): Return the real drop effect constant matching 'op'
} }
void BrowserDropDelegate::OnDragLeave(IDataObject* data_object) { void BrowserDropDelegate::OnDragLeave(IDataObject* data_object) {
webview_->dragTargetDragLeave(); webview_->dragTargetDragLeave();
} }
DWORD BrowserDropDelegate::OnDrop(IDataObject* data_object, DWORD BrowserDropDelegate::OnDrop(IDataObject* data_object,
DWORD key_state, DWORD key_state,
POINT cursor_position, POINT cursor_position,
DWORD effect) { DWORD effect) {
POINT client_pt = cursor_position; POINT client_pt = cursor_position;
ScreenToClient(GetHWND(), &client_pt); ScreenToClient(GetHWND(), &client_pt);
webview_->dragTargetDrop( webview_->dragTargetDrop(
WebPoint(client_pt.x, client_pt.y), WebPoint(client_pt.x, client_pt.y),
WebPoint(cursor_position.x, cursor_position.y)); WebPoint(cursor_position.x, cursor_position.y));
// webkit win port always returns DROPEFFECT_NONE // webkit win port always returns DROPEFFECT_NONE
return DROPEFFECT_NONE; return DROPEFFECT_NONE;
} }

View File

@ -1,45 +1,45 @@
// Copyright (c) 2008 The Chromium Embedded Framework Authors. // Copyright (c) 2008 The Chromium Embedded Framework Authors.
// Portions copyright (c) 2006-2008 The Chromium Authors. All rights reserved. // Portions copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// //
// A class that implements BaseDropTarget for the test shell webview delegate. // A class that implements BaseDropTarget for the test shell webview delegate.
#ifndef _BROWSER_DROP_DELEGATE_H #ifndef _BROWSER_DROP_DELEGATE_H
#define _BROWSER_DROP_DELEGATE_H #define _BROWSER_DROP_DELEGATE_H
#include "base/base_drop_target.h" #include "base/base_drop_target.h"
namespace WebKit { namespace WebKit {
class WebView; class WebView;
} }
class BrowserDropDelegate : public BaseDropTarget { class BrowserDropDelegate : public BaseDropTarget {
public: public:
BrowserDropDelegate(HWND source_hwnd, WebKit::WebView* webview) BrowserDropDelegate(HWND source_hwnd, WebKit::WebView* webview)
: BaseDropTarget(source_hwnd), : BaseDropTarget(source_hwnd),
webview_(webview) { } webview_(webview) { }
protected: protected:
// BaseDropTarget methods // BaseDropTarget methods
virtual DWORD OnDragEnter(IDataObject* data_object, virtual DWORD OnDragEnter(IDataObject* data_object,
DWORD key_state, DWORD key_state,
POINT cursor_position, POINT cursor_position,
DWORD effect); DWORD effect);
virtual DWORD OnDragOver(IDataObject* data_object, virtual DWORD OnDragOver(IDataObject* data_object,
DWORD key_state, DWORD key_state,
POINT cursor_position, POINT cursor_position,
DWORD effect); DWORD effect);
virtual void OnDragLeave(IDataObject* data_object); virtual void OnDragLeave(IDataObject* data_object);
virtual DWORD OnDrop(IDataObject* data_object, virtual DWORD OnDrop(IDataObject* data_object,
DWORD key_state, DWORD key_state,
POINT cursor_position, POINT cursor_position,
DWORD effect); DWORD effect);
private: private:
WebKit::WebView* webview_; WebKit::WebView* webview_;
}; };
#endif // _BROWSER_DROP_DELEGATE_H #endif // _BROWSER_DROP_DELEGATE_H

File diff suppressed because it is too large Load Diff

View File

@ -1,309 +1,309 @@
// Copyright (c) 2008-2009 The Chromium Embedded Framework Authors. // Copyright (c) 2008-2009 The Chromium Embedded Framework Authors.
// Portions copyright (c) 2006-2008 The Chromium Authors. All rights reserved. // Portions copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef _BROWSER_IMPL_H #ifndef _BROWSER_IMPL_H
#define _BROWSER_IMPL_H #define _BROWSER_IMPL_H
#include "include/cef.h" #include "include/cef.h"
#include "webview_host.h" #include "webview_host.h"
#include "browser_webview_delegate.h" #include "browser_webview_delegate.h"
#include "browser_navigation_controller.h" #include "browser_navigation_controller.h"
#include "cef_thread.h" #include "cef_thread.h"
#if defined(OS_WIN) #if defined(OS_WIN)
#include "printing/win_printing_context.h" #include "printing/win_printing_context.h"
#endif #endif
#include "base/scoped_temp_dir.h" #include "base/scoped_temp_dir.h"
#include "third_party/WebKit/WebKit/chromium/public/WebFindOptions.h" #include "third_party/WebKit/WebKit/chromium/public/WebFindOptions.h"
namespace base { namespace base {
class WaitableEvent; class WaitableEvent;
} }
namespace WebKit { namespace WebKit {
class WebView; class WebView;
} }
#define BUFFER_SIZE 32768 #define BUFFER_SIZE 32768
// Implementation of CefBrowser. // Implementation of CefBrowser.
class CefBrowserImpl : public CefThreadSafeBase<CefBrowser> class CefBrowserImpl : public CefThreadSafeBase<CefBrowser>
{ {
public: public:
CefBrowserImpl(CefWindowInfo& windowInfo, bool popup, CefBrowserImpl(CefWindowInfo& windowInfo, bool popup,
CefRefPtr<CefHandler> handler); CefRefPtr<CefHandler> handler);
virtual ~CefBrowserImpl() {} virtual ~CefBrowserImpl() {}
#if defined(OS_WIN) #if defined(OS_WIN)
static LPCTSTR GetWndClass(); static LPCTSTR GetWndClass();
static LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, static LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam,
LPARAM lParam); LPARAM lParam);
#endif #endif
// CefBrowser methods // CefBrowser methods
virtual bool CanGoBack(); virtual bool CanGoBack();
virtual void GoBack(); virtual void GoBack();
virtual bool CanGoForward(); virtual bool CanGoForward();
virtual void GoForward(); virtual void GoForward();
virtual void Reload(); virtual void Reload();
virtual void ReloadIgnoreCache(); virtual void ReloadIgnoreCache();
virtual void StopLoad(); virtual void StopLoad();
virtual void SetFocus(bool enable); virtual void SetFocus(bool enable);
virtual CefWindowHandle GetWindowHandle(); virtual CefWindowHandle GetWindowHandle();
virtual bool IsPopup(); virtual bool IsPopup();
virtual CefRefPtr<CefHandler> GetHandler(); virtual CefRefPtr<CefHandler> GetHandler();
virtual CefRefPtr<CefFrame> GetMainFrame(); virtual CefRefPtr<CefFrame> GetMainFrame();
virtual CefRefPtr<CefFrame> GetFocusedFrame(); virtual CefRefPtr<CefFrame> GetFocusedFrame();
virtual CefRefPtr<CefFrame> GetFrame(const std::wstring& name); virtual CefRefPtr<CefFrame> GetFrame(const std::wstring& name);
virtual void GetFrameNames(std::vector<std::wstring>& names); virtual void GetFrameNames(std::vector<std::wstring>& names);
virtual void Find(int identifier, const std::wstring& searchText, virtual void Find(int identifier, const std::wstring& searchText,
bool forward, bool matchCase, bool findNext); bool forward, bool matchCase, bool findNext);
virtual void StopFinding(bool clearSelection); virtual void StopFinding(bool clearSelection);
// CefFrames are light-weight objects managed by the browser and loosely // CefFrames are light-weight objects managed by the browser and loosely
// coupled to a WebFrame object by name. If a CefFrame object does not // coupled to a WebFrame object by name. If a CefFrame object does not
// already exist for the specified WebFrame one will be created. There is no // already exist for the specified WebFrame one will be created. There is no
// guarantee that the same CefFrame object will be returned across different // guarantee that the same CefFrame object will be returned across different
// calls to this function. // calls to this function.
CefRefPtr<CefFrame> GetCefFrame(WebKit::WebFrame* frame); CefRefPtr<CefFrame> GetCefFrame(WebKit::WebFrame* frame);
void RemoveCefFrame(const std::wstring& name); void RemoveCefFrame(const std::wstring& name);
// Return the WebFrame object associated with the specified CefFrame. This // Return the WebFrame object associated with the specified CefFrame. This
// may return NULL if no WebFrame with the CefFrame's name exists. // may return NULL if no WebFrame with the CefFrame's name exists.
WebKit::WebFrame* GetWebFrame(CefRefPtr<CefFrame> frame); WebKit::WebFrame* GetWebFrame(CefRefPtr<CefFrame> frame);
// Frame-related methods // Frame-related methods
void Undo(CefRefPtr<CefFrame> frame); void Undo(CefRefPtr<CefFrame> frame);
void Redo(CefRefPtr<CefFrame> frame); void Redo(CefRefPtr<CefFrame> frame);
void Cut(CefRefPtr<CefFrame> frame); void Cut(CefRefPtr<CefFrame> frame);
void Copy(CefRefPtr<CefFrame> frame); void Copy(CefRefPtr<CefFrame> frame);
void Paste(CefRefPtr<CefFrame> frame); void Paste(CefRefPtr<CefFrame> frame);
void Delete(CefRefPtr<CefFrame> frame); void Delete(CefRefPtr<CefFrame> frame);
void SelectAll(CefRefPtr<CefFrame> frame); void SelectAll(CefRefPtr<CefFrame> frame);
void Print(CefRefPtr<CefFrame> frame); void Print(CefRefPtr<CefFrame> frame);
void ViewSource(CefRefPtr<CefFrame> frame); void ViewSource(CefRefPtr<CefFrame> frame);
std::wstring GetSource(CefRefPtr<CefFrame> frame); std::wstring GetSource(CefRefPtr<CefFrame> frame);
std::wstring GetText(CefRefPtr<CefFrame> frame); std::wstring GetText(CefRefPtr<CefFrame> frame);
void LoadRequest(CefRefPtr<CefFrame> frame, void LoadRequest(CefRefPtr<CefFrame> frame,
CefRefPtr<CefRequest> request); CefRefPtr<CefRequest> request);
void LoadURL(CefRefPtr<CefFrame> frame, void LoadURL(CefRefPtr<CefFrame> frame,
const std::wstring& url); const std::wstring& url);
void LoadString(CefRefPtr<CefFrame> frame, void LoadString(CefRefPtr<CefFrame> frame,
const std::wstring& string, const std::wstring& string,
const std::wstring& url); const std::wstring& url);
void LoadStream(CefRefPtr<CefFrame> frame, void LoadStream(CefRefPtr<CefFrame> frame,
CefRefPtr<CefStreamReader> stream, CefRefPtr<CefStreamReader> stream,
const std::wstring& url); const std::wstring& url);
void ExecuteJavaScript(CefRefPtr<CefFrame> frame, void ExecuteJavaScript(CefRefPtr<CefFrame> frame,
const std::wstring& jsCode, const std::wstring& jsCode,
const std::wstring& scriptUrl, const std::wstring& scriptUrl,
int startLine); int startLine);
std::wstring GetURL(CefRefPtr<CefFrame> frame); std::wstring GetURL(CefRefPtr<CefFrame> frame);
WebKit::WebView* GetWebView() const { WebKit::WebView* GetWebView() const {
return webviewhost_.get() ? webviewhost_->webview() : NULL; return webviewhost_.get() ? webviewhost_->webview() : NULL;
} }
WebViewHost* GetWebViewHost() const { WebViewHost* GetWebViewHost() const {
return webviewhost_.get(); return webviewhost_.get();
} }
BrowserWebViewDelegate* GetWebViewDelegate() const { BrowserWebViewDelegate* GetWebViewDelegate() const {
return delegate_.get(); return delegate_.get();
} }
HWND GetWebViewWndHandle() const { HWND GetWebViewWndHandle() const {
return webviewhost_->view_handle(); return webviewhost_->view_handle();
} }
WebKit::WebWidget* GetPopup() const { WebKit::WebWidget* GetPopup() const {
return popuphost_ ? popuphost_->webwidget() : NULL; return popuphost_ ? popuphost_->webwidget() : NULL;
} }
WebWidgetHost* GetPopupHost() const { WebWidgetHost* GetPopupHost() const {
return popuphost_; return popuphost_;
} }
BrowserWebViewDelegate* GetPopupDelegate() const { BrowserWebViewDelegate* GetPopupDelegate() const {
return popup_delegate_.get(); return popup_delegate_.get();
} }
HWND GetPopupWndHandle() const { HWND GetPopupWndHandle() const {
return popuphost_->view_handle(); return popuphost_->view_handle();
} }
HWND GetMainWndHandle() const { HWND GetMainWndHandle() const {
return window_info_.m_hWnd; return window_info_.m_hWnd;
} }
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
// ALL UIT_* METHODS MUST ONLY BE CALLED ON THE UI THREAD // // ALL UIT_* METHODS MUST ONLY BE CALLED ON THE UI THREAD //
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
BrowserNavigationController* UIT_GetNavigationController() { BrowserNavigationController* UIT_GetNavigationController() {
REQUIRE_UIT(); REQUIRE_UIT();
return nav_controller_.get(); return nav_controller_.get();
} }
// Return true to allow user editing such as entering text in form elements // Return true to allow user editing such as entering text in form elements
bool UIT_AllowEditing() { return true; } bool UIT_AllowEditing() { return true; }
bool UIT_IsModal() { bool UIT_IsModal() {
REQUIRE_UIT(); REQUIRE_UIT();
return is_modal_; return is_modal_;
} }
void UIT_SetIsModal(bool val) { void UIT_SetIsModal(bool val) {
REQUIRE_UIT(); REQUIRE_UIT();
is_modal_ = val; is_modal_ = val;
} }
void UIT_SetTitle(const std::wstring& title) { void UIT_SetTitle(const std::wstring& title) {
REQUIRE_UIT(); REQUIRE_UIT();
title_ = title; title_ = title;
} }
std::wstring UIT_GetTitle() { std::wstring UIT_GetTitle() {
REQUIRE_UIT(); REQUIRE_UIT();
return title_; return title_;
} }
void UIT_CreateBrowser(const std::wstring& url); void UIT_CreateBrowser(const std::wstring& url);
void UIT_LoadURL(CefFrame* frame, void UIT_LoadURL(CefFrame* frame,
const std::wstring& url); const std::wstring& url);
void UIT_LoadURLForRequest(CefFrame* frame, void UIT_LoadURLForRequest(CefFrame* frame,
const std::wstring& url, const std::wstring& url,
const std::wstring& method, const std::wstring& method,
const WebKit::WebHTTPBody& upload_data, const WebKit::WebHTTPBody& upload_data,
const CefRequest::HeaderMap& headers); const CefRequest::HeaderMap& headers);
void UIT_LoadURLForRequestRef(CefFrame* frame, void UIT_LoadURLForRequestRef(CefFrame* frame,
CefRequest* request); CefRequest* request);
void UIT_LoadHTML(CefFrame* frame, void UIT_LoadHTML(CefFrame* frame,
const std::wstring& html, const std::wstring& html,
const std::wstring& url); const std::wstring& url);
void UIT_LoadHTMLForStreamRef(CefFrame* frame, void UIT_LoadHTMLForStreamRef(CefFrame* frame,
CefStreamReader* stream, CefStreamReader* stream,
const std::wstring& url); const std::wstring& url);
void UIT_ExecuteJavaScript(CefFrame* frame, void UIT_ExecuteJavaScript(CefFrame* frame,
const std::wstring& js_code, const std::wstring& js_code,
const std::wstring& script_url, const std::wstring& script_url,
int start_line); int start_line);
void UIT_GoBackOrForward(int offset); void UIT_GoBackOrForward(int offset);
void UIT_Reload(bool ignoreCache); void UIT_Reload(bool ignoreCache);
bool UIT_Navigate(const BrowserNavigationEntry& entry, bool UIT_Navigate(const BrowserNavigationEntry& entry,
bool reload, bool reload,
bool ignoreCahce); bool ignoreCahce);
void UIT_SetFocus(WebWidgetHost* host, bool enable); void UIT_SetFocus(WebWidgetHost* host, bool enable);
CefRefPtr<CefBrowserImpl> UIT_CreatePopupWindow(const std::wstring& url); CefRefPtr<CefBrowserImpl> UIT_CreatePopupWindow(const std::wstring& url);
WebKit::WebWidget* UIT_CreatePopupWidget(); WebKit::WebWidget* UIT_CreatePopupWidget();
void UIT_ClosePopupWidget(); void UIT_ClosePopupWidget();
void UIT_Show(WebKit::WebNavigationPolicy policy); void UIT_Show(WebKit::WebNavigationPolicy policy);
// Handles most simple browser actions // Handles most simple browser actions
void UIT_HandleActionView(CefHandler::MenuId menuId); void UIT_HandleActionView(CefHandler::MenuId menuId);
void UIT_HandleAction(CefHandler::MenuId menuId, CefFrame* frame); void UIT_HandleAction(CefHandler::MenuId menuId, CefFrame* frame);
// Save the document HTML to a temporary file and open in the default viewing // Save the document HTML to a temporary file and open in the default viewing
// application // application
bool UIT_ViewDocumentString(WebKit::WebFrame *frame); bool UIT_ViewDocumentString(WebKit::WebFrame *frame);
void UIT_GetDocumentStringNotify(CefFrame* frame, void UIT_GetDocumentStringNotify(CefFrame* frame,
CefStreamWriter* writer, CefStreamWriter* writer,
base::WaitableEvent* event); base::WaitableEvent* event);
void UIT_GetDocumentTextNotify(CefFrame* frame, CefStreamWriter* writer, void UIT_GetDocumentTextNotify(CefFrame* frame, CefStreamWriter* writer,
base::WaitableEvent* event); base::WaitableEvent* event);
void UIT_CanGoBackNotify(bool *retVal, base::WaitableEvent* event); void UIT_CanGoBackNotify(bool *retVal, base::WaitableEvent* event);
void UIT_CanGoForwardNotify(bool *retVal, base::WaitableEvent* event); void UIT_CanGoForwardNotify(bool *retVal, base::WaitableEvent* event);
bool UIT_CanGoBack() { return !nav_controller_->IsAtStart(); } bool UIT_CanGoBack() { return !nav_controller_->IsAtStart(); }
bool UIT_CanGoForward() { return !nav_controller_->IsAtEnd(); } bool UIT_CanGoForward() { return !nav_controller_->IsAtEnd(); }
// Printing support // Printing support
void UIT_PrintPages(WebKit::WebFrame* frame); void UIT_PrintPages(WebKit::WebFrame* frame);
void UIT_PrintPage(int page_number, int total_pages, void UIT_PrintPage(int page_number, int total_pages,
const gfx::Size& canvas_size, WebKit::WebFrame* frame); const gfx::Size& canvas_size, WebKit::WebFrame* frame);
int UIT_GetPagesCount(WebKit::WebFrame* frame); int UIT_GetPagesCount(WebKit::WebFrame* frame);
void UIT_SetUniqueID(int id) { unique_id_ = id; } void UIT_SetUniqueID(int id) { unique_id_ = id; }
int UIT_GetUniqueID() { return unique_id_; } int UIT_GetUniqueID() { return unique_id_; }
void UIT_Find(int identifier, const std::wstring& search_text, void UIT_Find(int identifier, const std::wstring& search_text,
const WebKit::WebFindOptions& options); const WebKit::WebFindOptions& options);
void UIT_StopFinding(bool clear_selection); void UIT_StopFinding(bool clear_selection);
void UIT_NotifyFindStatus(int identifier, int count, void UIT_NotifyFindStatus(int identifier, int count,
const WebKit::WebRect& selection_rect, const WebKit::WebRect& selection_rect,
int active_match_ordinal, bool final_update); int active_match_ordinal, bool final_update);
static bool ImplementsThreadSafeReferenceCounting() { return true; } static bool ImplementsThreadSafeReferenceCounting() { return true; }
const FilePath& file_system_root() const { return file_system_root_.path(); } const FilePath& file_system_root() const { return file_system_root_.path(); }
protected: protected:
CefWindowInfo window_info_; CefWindowInfo window_info_;
bool is_popup_; bool is_popup_;
bool is_modal_; bool is_modal_;
CefRefPtr<CefHandler> handler_; CefRefPtr<CefHandler> handler_;
scoped_ptr<WebViewHost> webviewhost_; scoped_ptr<WebViewHost> webviewhost_;
WebWidgetHost* popuphost_; WebWidgetHost* popuphost_;
scoped_ptr<BrowserWebViewDelegate> delegate_; scoped_ptr<BrowserWebViewDelegate> delegate_;
scoped_ptr<BrowserWebViewDelegate> popup_delegate_; scoped_ptr<BrowserWebViewDelegate> popup_delegate_;
scoped_ptr<BrowserNavigationController> nav_controller_; scoped_ptr<BrowserNavigationController> nav_controller_;
std::wstring title_; std::wstring title_;
// Context object used to manage printing. // Context object used to manage printing.
printing::PrintingContext print_context_; printing::PrintingContext print_context_;
typedef std::map<std::wstring, CefFrame*> FrameMap; typedef std::map<std::wstring, CefFrame*> FrameMap;
FrameMap frames_; FrameMap frames_;
CefFrame* frame_main_; CefFrame* frame_main_;
// Unique browser ID assigned by the context. // Unique browser ID assigned by the context.
int unique_id_; int unique_id_;
// A temporary directory for FileSystem API. // A temporary directory for FileSystem API.
ScopedTempDir file_system_root_; ScopedTempDir file_system_root_;
}; };
// Implementation of CefFrame. // Implementation of CefFrame.
class CefFrameImpl : public CefThreadSafeBase<CefFrame> class CefFrameImpl : public CefThreadSafeBase<CefFrame>
{ {
public: public:
CefFrameImpl(CefBrowserImpl* browser, const std::wstring& name) CefFrameImpl(CefBrowserImpl* browser, const std::wstring& name)
: browser_(browser), name_(name) {} : browser_(browser), name_(name) {}
virtual ~CefFrameImpl() { browser_->RemoveCefFrame(name_); } virtual ~CefFrameImpl() { browser_->RemoveCefFrame(name_); }
// CefFrame methods // CefFrame methods
virtual void Undo() { browser_->Undo(this); } virtual void Undo() { browser_->Undo(this); }
virtual void Redo() { browser_->Redo(this); } virtual void Redo() { browser_->Redo(this); }
virtual void Cut() { browser_->Cut(this); } virtual void Cut() { browser_->Cut(this); }
virtual void Copy() { browser_->Copy(this); } virtual void Copy() { browser_->Copy(this); }
virtual void Paste() { browser_->Paste(this); } virtual void Paste() { browser_->Paste(this); }
virtual void Delete() { browser_->Delete(this); } virtual void Delete() { browser_->Delete(this); }
virtual void SelectAll() { browser_->SelectAll(this); } virtual void SelectAll() { browser_->SelectAll(this); }
virtual void Print() { browser_->Print(this); } virtual void Print() { browser_->Print(this); }
virtual void ViewSource() { browser_->ViewSource(this); } virtual void ViewSource() { browser_->ViewSource(this); }
virtual std::wstring GetSource() { return browser_->GetSource(this); } virtual std::wstring GetSource() { return browser_->GetSource(this); }
virtual std::wstring GetText() { return browser_->GetText(this); } virtual std::wstring GetText() { return browser_->GetText(this); }
virtual void LoadRequest(CefRefPtr<CefRequest> request) virtual void LoadRequest(CefRefPtr<CefRequest> request)
{ return browser_->LoadRequest(this, request); } { return browser_->LoadRequest(this, request); }
virtual void LoadURL(const std::wstring& url) virtual void LoadURL(const std::wstring& url)
{ return browser_->LoadURL(this, url); } { return browser_->LoadURL(this, url); }
virtual void LoadString(const std::wstring& string, virtual void LoadString(const std::wstring& string,
const std::wstring& url) const std::wstring& url)
{ return browser_->LoadString(this, string, url); } { return browser_->LoadString(this, string, url); }
virtual void LoadStream(CefRefPtr<CefStreamReader> stream, virtual void LoadStream(CefRefPtr<CefStreamReader> stream,
const std::wstring& url) const std::wstring& url)
{ return browser_->LoadStream(this, stream, url); } { return browser_->LoadStream(this, stream, url); }
virtual void ExecuteJavaScript(const std::wstring& jsCode, virtual void ExecuteJavaScript(const std::wstring& jsCode,
const std::wstring& scriptUrl, const std::wstring& scriptUrl,
int startLine) int startLine)
{ return browser_->ExecuteJavaScript(this, jsCode, scriptUrl, startLine); } { return browser_->ExecuteJavaScript(this, jsCode, scriptUrl, startLine); }
virtual bool IsMain() { return name_.empty(); } virtual bool IsMain() { return name_.empty(); }
virtual bool IsFocused(); virtual bool IsFocused();
virtual std::wstring GetName() { return name_; } virtual std::wstring GetName() { return name_; }
virtual std::wstring GetURL() { return browser_->GetURL(this); } virtual std::wstring GetURL() { return browser_->GetURL(this); }
private: private:
CefRefPtr<CefBrowserImpl> browser_; CefRefPtr<CefBrowserImpl> browser_;
std::wstring name_; std::wstring name_;
}; };
#endif // _BROWSER_IMPL_H #endif // _BROWSER_IMPL_H

View File

@ -1,478 +1,478 @@
// Copyright (c) 2008-2009 The Chromium Embedded Framework Authors. // Copyright (c) 2008-2009 The Chromium Embedded Framework Authors.
// Portions copyright (c) 2006-2008 The Chromium Authors. All rights reserved. // Portions copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "cef_context.h" #include "cef_context.h"
#include "browser_impl.h" #include "browser_impl.h"
#include "printing/units.h" #include "printing/units.h"
#include "base/utf_string_conversions.h" #include "base/utf_string_conversions.h"
#include "base/win_util.h" #include "base/win_util.h"
#include "skia/ext/vector_canvas.h" #include "skia/ext/vector_canvas.h"
#include "third_party/WebKit/WebKit/chromium/public/WebFrame.h" #include "third_party/WebKit/WebKit/chromium/public/WebFrame.h"
#include "third_party/WebKit/WebKit/chromium/public/WebRect.h" #include "third_party/WebKit/WebKit/chromium/public/WebRect.h"
#include "third_party/WebKit/WebKit/chromium/public/WebSize.h" #include "third_party/WebKit/WebKit/chromium/public/WebSize.h"
#include "third_party/WebKit/WebKit/chromium/public/WebView.h" #include "third_party/WebKit/WebKit/chromium/public/WebView.h"
#include <shellapi.h> #include <shellapi.h>
#include <shlwapi.h> #include <shlwapi.h>
#include <wininet.h> #include <wininet.h>
#include <winspool.h> #include <winspool.h>
using WebKit::WebRect; using WebKit::WebRect;
using WebKit::WebSize; using WebKit::WebSize;
LPCTSTR CefBrowserImpl::GetWndClass() LPCTSTR CefBrowserImpl::GetWndClass()
{ {
return L"CefBrowserWindow"; return L"CefBrowserWindow";
} }
LRESULT CALLBACK CefBrowserImpl::WndProc(HWND hwnd, UINT message, LRESULT CALLBACK CefBrowserImpl::WndProc(HWND hwnd, UINT message,
WPARAM wParam, LPARAM lParam) WPARAM wParam, LPARAM lParam)
{ {
CefBrowserImpl* browser = CefBrowserImpl* browser =
static_cast<CefBrowserImpl*>(win_util::GetWindowUserData(hwnd)); static_cast<CefBrowserImpl*>(win_util::GetWindowUserData(hwnd));
switch (message) { switch (message) {
case WM_COMMAND: case WM_COMMAND:
{ {
int wmId = LOWORD(wParam); int wmId = LOWORD(wParam);
int wmEvent = HIWORD(wParam); int wmEvent = HIWORD(wParam);
} }
break; break;
case WM_DESTROY: case WM_DESTROY:
if (browser) if (browser)
{ {
CefRefPtr<CefHandler> handler = browser->GetHandler(); CefRefPtr<CefHandler> handler = browser->GetHandler();
if(handler.get()) { if(handler.get()) {
// Notify the handler that the window is about to be closed // Notify the handler that the window is about to be closed
handler->HandleBeforeWindowClose(browser); handler->HandleBeforeWindowClose(browser);
} }
browser->GetWebViewDelegate()->RevokeDragDrop(); browser->GetWebViewDelegate()->RevokeDragDrop();
// Clean up anything associated with the WebViewHost widget. // Clean up anything associated with the WebViewHost widget.
browser->GetWebViewHost()->webwidget()->close(); browser->GetWebViewHost()->webwidget()->close();
browser->webviewhost_.reset(); browser->webviewhost_.reset();
// Clear the user data pointer. // Clear the user data pointer.
win_util::SetWindowUserData(hwnd, NULL); win_util::SetWindowUserData(hwnd, NULL);
// Remove the reference added in UIT_CreateBrowser(). // Remove the reference added in UIT_CreateBrowser().
browser->Release(); browser->Release();
// Remove the browser from the list maintained by the context // Remove the browser from the list maintained by the context
_Context->RemoveBrowser(browser); _Context->RemoveBrowser(browser);
} }
return 0; return 0;
case WM_SIZE: case WM_SIZE:
if (browser && browser->GetWebView()) { if (browser && browser->GetWebView()) {
// resize the web view window to the full size of the browser window // resize the web view window to the full size of the browser window
RECT rc; RECT rc;
GetClientRect(browser->GetMainWndHandle(), &rc); GetClientRect(browser->GetMainWndHandle(), &rc);
MoveWindow(browser->GetWebViewWndHandle(), 0, 0, rc.right, rc.bottom, MoveWindow(browser->GetWebViewWndHandle(), 0, 0, rc.right, rc.bottom,
TRUE); TRUE);
} }
return 0; return 0;
case WM_SETFOCUS: case WM_SETFOCUS:
if (browser && browser->GetWebView()) if (browser && browser->GetWebView())
browser->GetWebView()->setFocus(true); browser->GetWebView()->setFocus(true);
return 0; return 0;
case WM_KILLFOCUS: case WM_KILLFOCUS:
if (browser && browser->GetWebView()) if (browser && browser->GetWebView())
browser->GetWebView()->setFocus(false); browser->GetWebView()->setFocus(false);
return 0; return 0;
case WM_ERASEBKGND: case WM_ERASEBKGND:
return 0; return 0;
} }
return DefWindowProc(hwnd, message, wParam, lParam); return DefWindowProc(hwnd, message, wParam, lParam);
} }
CefWindowHandle CefBrowserImpl::GetWindowHandle() CefWindowHandle CefBrowserImpl::GetWindowHandle()
{ {
Lock(); Lock();
CefWindowHandle handle = window_info_.m_hWnd; CefWindowHandle handle = window_info_.m_hWnd;
Unlock(); Unlock();
return handle; return handle;
} }
void CefBrowserImpl::UIT_CreateBrowser(const std::wstring& url) void CefBrowserImpl::UIT_CreateBrowser(const std::wstring& url)
{ {
REQUIRE_UIT(); REQUIRE_UIT();
// Create the new browser window // Create the new browser window
window_info_.m_hWnd = CreateWindowEx(window_info_.m_dwExStyle, GetWndClass(), window_info_.m_hWnd = CreateWindowEx(window_info_.m_dwExStyle, GetWndClass(),
window_info_.m_windowName, window_info_.m_dwStyle, window_info_.m_windowName, window_info_.m_dwStyle,
window_info_.m_x, window_info_.m_y, window_info_.m_nWidth, window_info_.m_x, window_info_.m_y, window_info_.m_nWidth,
window_info_.m_nHeight, window_info_.m_hWndParent, window_info_.m_hMenu, window_info_.m_nHeight, window_info_.m_hWndParent, window_info_.m_hMenu,
::GetModuleHandle(NULL), NULL); ::GetModuleHandle(NULL), NULL);
DCHECK(window_info_.m_hWnd != NULL); DCHECK(window_info_.m_hWnd != NULL);
// Set window user data to this object for future reference from the window // Set window user data to this object for future reference from the window
// procedure // procedure
win_util::SetWindowUserData(window_info_.m_hWnd, this); win_util::SetWindowUserData(window_info_.m_hWnd, this);
// Add a reference that will be released on WM_DESTROY. // Add a reference that will be released on WM_DESTROY.
AddRef(); AddRef();
// Add the new browser to the list maintained by the context // Add the new browser to the list maintained by the context
_Context->AddBrowser(this); _Context->AddBrowser(this);
// Create the webview host object // Create the webview host object
webviewhost_.reset( webviewhost_.reset(
WebViewHost::Create(window_info_.m_hWnd, delegate_.get(), NULL, WebViewHost::Create(window_info_.m_hWnd, delegate_.get(), NULL,
*_Context->web_preferences())); *_Context->web_preferences()));
delegate_->RegisterDragDrop(); delegate_->RegisterDragDrop();
// Size the web view window to the browser window // Size the web view window to the browser window
RECT cr; RECT cr;
GetClientRect(window_info_.m_hWnd, &cr); GetClientRect(window_info_.m_hWnd, &cr);
SetWindowPos(GetWebViewWndHandle(), NULL, cr.left, cr.top, cr.right, SetWindowPos(GetWebViewWndHandle(), NULL, cr.left, cr.top, cr.right,
cr.bottom, SWP_NOZORDER | SWP_SHOWWINDOW); cr.bottom, SWP_NOZORDER | SWP_SHOWWINDOW);
if(handler_.get()) { if(handler_.get()) {
// Notify the handler that we're done creating the new window // Notify the handler that we're done creating the new window
handler_->HandleAfterCreated(this); handler_->HandleAfterCreated(this);
} }
if(url.size() > 0) { if(url.size() > 0) {
CefRefPtr<CefFrame> frame = GetMainFrame(); CefRefPtr<CefFrame> frame = GetMainFrame();
frame->AddRef(); frame->AddRef();
UIT_LoadURL(frame, url.c_str()); UIT_LoadURL(frame, url.c_str());
} }
} }
void CefBrowserImpl::UIT_SetFocus(WebWidgetHost* host, bool enable) void CefBrowserImpl::UIT_SetFocus(WebWidgetHost* host, bool enable)
{ {
REQUIRE_UIT(); REQUIRE_UIT();
if (!host) if (!host)
return; return;
if (enable) if (enable)
::SetFocus(host->view_handle()); ::SetFocus(host->view_handle());
else if (::GetFocus() == host->view_handle()) else if (::GetFocus() == host->view_handle())
::SetFocus(NULL); ::SetFocus(NULL);
} }
WebKit::WebWidget* CefBrowserImpl::UIT_CreatePopupWidget() WebKit::WebWidget* CefBrowserImpl::UIT_CreatePopupWidget()
{ {
REQUIRE_UIT(); REQUIRE_UIT();
DCHECK(!popuphost_); DCHECK(!popuphost_);
popuphost_ = WebWidgetHost::Create(NULL, popup_delegate_.get()); popuphost_ = WebWidgetHost::Create(NULL, popup_delegate_.get());
ShowWindow(GetPopupWndHandle(), SW_SHOW); ShowWindow(GetPopupWndHandle(), SW_SHOW);
return popuphost_->webwidget(); return popuphost_->webwidget();
} }
void CefBrowserImpl::UIT_ClosePopupWidget() void CefBrowserImpl::UIT_ClosePopupWidget()
{ {
REQUIRE_UIT(); REQUIRE_UIT();
PostMessage(GetPopupWndHandle(), WM_CLOSE, 0, 0); PostMessage(GetPopupWndHandle(), WM_CLOSE, 0, 0);
popuphost_ = NULL; popuphost_ = NULL;
} }
static void WriteTextToFile(const std::string& data, static void WriteTextToFile(const std::string& data,
const std::wstring& file_path) const std::wstring& file_path)
{ {
FILE* fp; FILE* fp;
errno_t err = _wfopen_s(&fp, file_path.c_str(), L"wt"); errno_t err = _wfopen_s(&fp, file_path.c_str(), L"wt");
if (err) if (err)
return; return;
fwrite(data.c_str(), 1, data.size(), fp); fwrite(data.c_str(), 1, data.size(), fp);
fclose(fp); fclose(fp);
} }
bool CefBrowserImpl::UIT_ViewDocumentString(WebKit::WebFrame *frame) bool CefBrowserImpl::UIT_ViewDocumentString(WebKit::WebFrame *frame)
{ {
REQUIRE_UIT(); REQUIRE_UIT();
DWORD dwRetVal; DWORD dwRetVal;
DWORD dwBufSize = 512; DWORD dwBufSize = 512;
TCHAR lpPathBuffer[512]; TCHAR lpPathBuffer[512];
UINT uRetVal; UINT uRetVal;
TCHAR szTempName[512]; TCHAR szTempName[512];
dwRetVal = GetTempPath(dwBufSize, // length of the buffer dwRetVal = GetTempPath(dwBufSize, // length of the buffer
lpPathBuffer); // buffer for path lpPathBuffer); // buffer for path
if (dwRetVal > dwBufSize || (dwRetVal == 0)) if (dwRetVal > dwBufSize || (dwRetVal == 0))
return false; return false;
// Create a temporary file. // Create a temporary file.
uRetVal = GetTempFileName(lpPathBuffer, // directory for tmp files uRetVal = GetTempFileName(lpPathBuffer, // directory for tmp files
TEXT("src"), // temp file name prefix TEXT("src"), // temp file name prefix
0, // create unique name 0, // create unique name
szTempName); // buffer for name szTempName); // buffer for name
if (uRetVal == 0) if (uRetVal == 0)
return false; return false;
size_t len = wcslen(szTempName); size_t len = wcslen(szTempName);
wcscpy(szTempName + len - 3, L"txt"); wcscpy(szTempName + len - 3, L"txt");
std::string markup = frame->contentAsMarkup().utf8(); std::string markup = frame->contentAsMarkup().utf8();
WriteTextToFile(markup, szTempName); WriteTextToFile(markup, szTempName);
int errorCode = (int)ShellExecute(GetMainWndHandle(), L"open", szTempName, int errorCode = (int)ShellExecute(GetMainWndHandle(), L"open", szTempName,
NULL, NULL, SW_SHOWNORMAL); NULL, NULL, SW_SHOWNORMAL);
if(errorCode <= 32) if(errorCode <= 32)
return false; return false;
return true; return true;
} }
void CefBrowserImpl::UIT_PrintPage(int page_number, int total_pages, void CefBrowserImpl::UIT_PrintPage(int page_number, int total_pages,
const gfx::Size& canvas_size, const gfx::Size& canvas_size,
WebKit::WebFrame* frame) { WebKit::WebFrame* frame) {
REQUIRE_UIT(); REQUIRE_UIT();
printing::PrintParams params; printing::PrintParams params;
const printing::PrintSettings &settings = print_context_.settings(); const printing::PrintSettings &settings = print_context_.settings();
settings.RenderParams(&params); settings.RenderParams(&params);
const int src_size_x = canvas_size.width(); const int src_size_x = canvas_size.width();
const int src_size_y = canvas_size.height(); const int src_size_y = canvas_size.height();
const int dest_size_x = settings.page_setup_pixels().printable_area().width(); const int dest_size_x = settings.page_setup_pixels().printable_area().width();
const int dest_size_y = settings.page_setup_pixels().printable_area().height(); const int dest_size_y = settings.page_setup_pixels().printable_area().height();
print_context_.NewPage(); print_context_.NewPage();
HDC hDC = print_context_.context(); HDC hDC = print_context_.context();
BOOL res; BOOL res;
// Save the state to make sure the context this function call does not modify // Save the state to make sure the context this function call does not modify
// the device context. // the device context.
int saved_state = SaveDC(hDC); int saved_state = SaveDC(hDC);
DCHECK_NE(saved_state, 0); DCHECK_NE(saved_state, 0);
skia::VectorCanvas canvas(hDC, dest_size_x, dest_size_y); skia::VectorCanvas canvas(hDC, dest_size_x, dest_size_y);
//The hDC 0 coord is the left most printeable area and not physical area of the paper //The hDC 0 coord is the left most printeable area and not physical area of the paper
//so subtract that out of our canvas translate. //so subtract that out of our canvas translate.
const int left_margin_offset = settings.page_setup_pixels().effective_margins().left - const int left_margin_offset = settings.page_setup_pixels().effective_margins().left -
settings.page_setup_pixels().printable_area().x(); settings.page_setup_pixels().printable_area().x();
const int top_margin_offset = settings.page_setup_pixels().effective_margins().top - const int top_margin_offset = settings.page_setup_pixels().effective_margins().top -
settings.page_setup_pixels().printable_area().y(); settings.page_setup_pixels().printable_area().y();
// Adjust for the margin offset. // Adjust for the margin offset.
canvas.translate(static_cast<float>(left_margin_offset), canvas.translate(static_cast<float>(left_margin_offset),
static_cast<float>(top_margin_offset)); static_cast<float>(top_margin_offset));
// Apply the print scaling factor. // Apply the print scaling factor.
const float print_scale_x = static_cast<float>(settings.page_setup_pixels().content_area().width()) const float print_scale_x = static_cast<float>(settings.page_setup_pixels().content_area().width())
/ src_size_x; / src_size_x;
const float print_scale_y = static_cast<float>(settings.page_setup_pixels().content_area().height()) const float print_scale_y = static_cast<float>(settings.page_setup_pixels().content_area().height())
/ src_size_y; / src_size_y;
canvas.scale(print_scale_x, print_scale_y); canvas.scale(print_scale_x, print_scale_y);
// Apply the WebKit scaling factor. // Apply the WebKit scaling factor.
const float webkit_scale = frame->getPrintPageShrink(page_number); const float webkit_scale = frame->getPrintPageShrink(page_number);
if (webkit_scale <= 0) { if (webkit_scale <= 0) {
NOTREACHED() << "Printing page " << page_number << " failed."; NOTREACHED() << "Printing page " << page_number << " failed.";
} }
canvas.scale(webkit_scale, webkit_scale); canvas.scale(webkit_scale, webkit_scale);
frame->printPage(page_number, &canvas); frame->printPage(page_number, &canvas);
res = RestoreDC(hDC, saved_state); res = RestoreDC(hDC, saved_state);
DCHECK_NE(res, 0); DCHECK_NE(res, 0);
if(handler_.get()) { if(handler_.get()) {
saved_state = SaveDC(hDC); saved_state = SaveDC(hDC);
DCHECK_NE(saved_state, 0); DCHECK_NE(saved_state, 0);
// Gather print header state information // Gather print header state information
RECT rect; RECT rect;
rect.left = left_margin_offset; rect.left = left_margin_offset;
rect.top = settings.page_setup_pixels().effective_margins().header - rect.top = settings.page_setup_pixels().effective_margins().header -
settings.page_setup_pixels().printable_area().y(); settings.page_setup_pixels().printable_area().y();
rect.right = left_margin_offset + settings.page_setup_pixels().content_area().width(); rect.right = left_margin_offset + settings.page_setup_pixels().content_area().width();
rect.bottom = settings.page_setup_pixels().printable_area().height() - rect.bottom = settings.page_setup_pixels().printable_area().height() -
(settings.page_setup_pixels().effective_margins().footer - (settings.page_setup_pixels().effective_margins().footer -
(settings.page_setup_pixels().physical_size().height() - (settings.page_setup_pixels().physical_size().height() -
settings.page_setup_pixels().printable_area().bottom())); settings.page_setup_pixels().printable_area().bottom()));
const double scale = static_cast<double>(settings.dpi()) / const double scale = static_cast<double>(settings.dpi()) /
static_cast<double>(settings.desired_dpi); static_cast<double>(settings.desired_dpi);
CefPrintInfo printInfo; CefPrintInfo printInfo;
printInfo.m_hDC = hDC; printInfo.m_hDC = hDC;
printInfo.m_Rect = rect; printInfo.m_Rect = rect;
printInfo.m_Scale = scale; printInfo.m_Scale = scale;
std::string spec = frame->url().spec(); std::string spec = frame->url().spec();
std::wstring url = UTF8ToWide(spec); std::wstring url = UTF8ToWide(spec);
std::wstring title = title_; std::wstring title = title_;
std::wstring topLeft, topCenter, topRight; std::wstring topLeft, topCenter, topRight;
std::wstring bottomLeft, bottomCenter, bottomRight; std::wstring bottomLeft, bottomCenter, bottomRight;
// allow the handler to format print header and/or footer // allow the handler to format print header and/or footer
CefHandler::RetVal rv = handler_->HandlePrintHeaderFooter(this, CefHandler::RetVal rv = handler_->HandlePrintHeaderFooter(this,
GetCefFrame(frame), printInfo, url, title, page_number+1, total_pages, GetCefFrame(frame), printInfo, url, title, page_number+1, total_pages,
topLeft, topCenter, topRight, bottomLeft, bottomCenter, bottomRight); topLeft, topCenter, topRight, bottomLeft, bottomCenter, bottomRight);
if(rv != RV_HANDLED) { if(rv != RV_HANDLED) {
// Draw handler-defined headers and/or footers. // Draw handler-defined headers and/or footers.
LOGFONT lf; LOGFONT lf;
memset(&lf, 0, sizeof(lf)); memset(&lf, 0, sizeof(lf));
lf.lfHeight = (int)ceil(10. * scale); lf.lfHeight = (int)ceil(10. * scale);
lf.lfPitchAndFamily = FF_SWISS; lf.lfPitchAndFamily = FF_SWISS;
HFONT hFont = CreateFontIndirect(&lf); HFONT hFont = CreateFontIndirect(&lf);
HFONT hOldFont = (HFONT)SelectObject(hDC, hFont); HFONT hOldFont = (HFONT)SelectObject(hDC, hFont);
COLORREF hOldColor = SetTextColor(hDC, RGB(0,0,0)); COLORREF hOldColor = SetTextColor(hDC, RGB(0,0,0));
int hOldBkMode = SetBkMode(hDC, TRANSPARENT); int hOldBkMode = SetBkMode(hDC, TRANSPARENT);
// TODO(cef): Keep the header strings inside a reasonable bounding box // TODO(cef): Keep the header strings inside a reasonable bounding box
// so that they don't overlap each other. // so that they don't overlap each other.
if(topLeft.size() > 0) { if(topLeft.size() > 0) {
DrawText(hDC, topLeft.c_str(), topLeft.size(), &rect, DrawText(hDC, topLeft.c_str(), topLeft.size(), &rect,
DT_LEFT | DT_TOP | DT_SINGLELINE | DT_END_ELLIPSIS DT_LEFT | DT_TOP | DT_SINGLELINE | DT_END_ELLIPSIS
| DT_EXPANDTABS | DT_NOPREFIX); | DT_EXPANDTABS | DT_NOPREFIX);
} }
if(topCenter.size() > 0) { if(topCenter.size() > 0) {
DrawText(hDC, topCenter.c_str(), topCenter.size(), &rect, DrawText(hDC, topCenter.c_str(), topCenter.size(), &rect,
DT_CENTER | DT_TOP | DT_SINGLELINE | DT_END_ELLIPSIS DT_CENTER | DT_TOP | DT_SINGLELINE | DT_END_ELLIPSIS
| DT_EXPANDTABS | DT_NOPREFIX); | DT_EXPANDTABS | DT_NOPREFIX);
} }
if(topRight.size() > 0) { if(topRight.size() > 0) {
DrawText(hDC, topRight.c_str(), topRight.size(), &rect, DrawText(hDC, topRight.c_str(), topRight.size(), &rect,
DT_RIGHT | DT_TOP | DT_SINGLELINE | DT_END_ELLIPSIS DT_RIGHT | DT_TOP | DT_SINGLELINE | DT_END_ELLIPSIS
| DT_EXPANDTABS | DT_NOPREFIX); | DT_EXPANDTABS | DT_NOPREFIX);
} }
if(bottomLeft.size() > 0) { if(bottomLeft.size() > 0) {
DrawText(hDC, bottomLeft.c_str(), bottomLeft.size(), &rect, DrawText(hDC, bottomLeft.c_str(), bottomLeft.size(), &rect,
DT_LEFT | DT_BOTTOM | DT_SINGLELINE | DT_END_ELLIPSIS DT_LEFT | DT_BOTTOM | DT_SINGLELINE | DT_END_ELLIPSIS
| DT_EXPANDTABS | DT_NOPREFIX); | DT_EXPANDTABS | DT_NOPREFIX);
} }
if(bottomCenter.size() > 0) { if(bottomCenter.size() > 0) {
DrawText(hDC, bottomCenter.c_str(), bottomCenter.size(), &rect, DrawText(hDC, bottomCenter.c_str(), bottomCenter.size(), &rect,
DT_CENTER | DT_BOTTOM | DT_SINGLELINE | DT_END_ELLIPSIS DT_CENTER | DT_BOTTOM | DT_SINGLELINE | DT_END_ELLIPSIS
| DT_EXPANDTABS | DT_NOPREFIX); | DT_EXPANDTABS | DT_NOPREFIX);
} }
if(bottomRight.size() > 0) { if(bottomRight.size() > 0) {
DrawText(hDC, bottomRight.c_str(), bottomRight.size(), &rect, DrawText(hDC, bottomRight.c_str(), bottomRight.size(), &rect,
DT_RIGHT | DT_BOTTOM | DT_SINGLELINE | DT_END_ELLIPSIS DT_RIGHT | DT_BOTTOM | DT_SINGLELINE | DT_END_ELLIPSIS
| DT_EXPANDTABS | DT_NOPREFIX); | DT_EXPANDTABS | DT_NOPREFIX);
} }
SetTextColor(hDC, hOldColor); SetTextColor(hDC, hOldColor);
SelectObject(hDC, hOldFont); SelectObject(hDC, hOldFont);
DeleteObject(hFont); DeleteObject(hFont);
SetBkMode(hDC, hOldBkMode); SetBkMode(hDC, hOldBkMode);
} }
res = RestoreDC(hDC, saved_state); res = RestoreDC(hDC, saved_state);
DCHECK_NE(res, 0); DCHECK_NE(res, 0);
} }
print_context_.PageDone(); print_context_.PageDone();
} }
void CefBrowserImpl::UIT_PrintPages(WebKit::WebFrame* frame) { void CefBrowserImpl::UIT_PrintPages(WebKit::WebFrame* frame) {
REQUIRE_UIT(); REQUIRE_UIT();
print_context_.Init(); print_context_.Init();
{ {
// Make a copy of settings. // Make a copy of settings.
printing::PrintSettings settings = print_context_.settings(); printing::PrintSettings settings = print_context_.settings();
cef_print_options_t print_options; cef_print_options_t print_options;
settings.UpdatePrintOptions(print_options); settings.UpdatePrintOptions(print_options);
// Ask the handler if they want to update the print options. // Ask the handler if they want to update the print options.
if (handler_.get() && RV_HANDLED == handler_->HandlePrintOptions(this, print_options)) { if (handler_.get() && RV_HANDLED == handler_->HandlePrintOptions(this, print_options)) {
settings.UpdateFromPrintOptions(print_options); settings.UpdateFromPrintOptions(print_options);
print_context_.InitWithSettings(settings); print_context_.InitWithSettings(settings);
} }
} }
if(print_context_.AskUserForSettings( if(print_context_.AskUserForSettings(
GetMainWndHandle(), UIT_GetPagesCount(frame), false) GetMainWndHandle(), UIT_GetPagesCount(frame), false)
!= printing::PrintingContext::OK) != printing::PrintingContext::OK)
return; return;
printing::PrintParams params; printing::PrintParams params;
const printing::PrintSettings &settings = print_context_.settings(); const printing::PrintSettings &settings = print_context_.settings();
settings.RenderParams(&params); settings.RenderParams(&params);
int page_count = 0; int page_count = 0;
gfx::Size canvas_size; gfx::Size canvas_size;
canvas_size.set_width( canvas_size.set_width(
printing::ConvertUnit( printing::ConvertUnit(
settings.page_setup_pixels().content_area().width(), settings.page_setup_pixels().content_area().width(),
static_cast<int>(params.dpi), static_cast<int>(params.dpi),
params.desired_dpi)); params.desired_dpi));
canvas_size.set_height( canvas_size.set_height(
printing::ConvertUnit( printing::ConvertUnit(
settings.page_setup_pixels().content_area().height(), settings.page_setup_pixels().content_area().height(),
static_cast<int>(params.dpi), static_cast<int>(params.dpi),
params.desired_dpi)); params.desired_dpi));
page_count = frame->printBegin(WebSize(canvas_size)); page_count = frame->printBegin(WebSize(canvas_size));
if (page_count) { if (page_count) {
bool old_state = MessageLoop::current()->NestableTasksAllowed(); bool old_state = MessageLoop::current()->NestableTasksAllowed();
MessageLoop::current()->SetNestableTasksAllowed(false); MessageLoop::current()->SetNestableTasksAllowed(false);
if (print_context_.NewDocument(title_) == printing::PrintingContext::OK) { if (print_context_.NewDocument(title_) == printing::PrintingContext::OK) {
if(settings.ranges.size() > 0) { if(settings.ranges.size() > 0) {
for (unsigned x = 0; x < settings.ranges.size(); ++x) { for (unsigned x = 0; x < settings.ranges.size(); ++x) {
const printing::PageRange& range = settings.ranges[x]; const printing::PageRange& range = settings.ranges[x];
for(int i = range.from; i <= range.to; ++i) for(int i = range.from; i <= range.to; ++i)
UIT_PrintPage(i, page_count, canvas_size, frame); UIT_PrintPage(i, page_count, canvas_size, frame);
} }
} else { } else {
for(int i = 0; i < page_count; ++i) for(int i = 0; i < page_count; ++i)
UIT_PrintPage(i, page_count, canvas_size, frame); UIT_PrintPage(i, page_count, canvas_size, frame);
} }
print_context_.DocumentDone(); print_context_.DocumentDone();
} }
MessageLoop::current()->SetNestableTasksAllowed(old_state); MessageLoop::current()->SetNestableTasksAllowed(old_state);
} }
frame->printEnd(); frame->printEnd();
} }
int CefBrowserImpl::UIT_GetPagesCount(WebKit::WebFrame* frame) int CefBrowserImpl::UIT_GetPagesCount(WebKit::WebFrame* frame)
{ {
REQUIRE_UIT(); REQUIRE_UIT();
printing::PrintParams params; printing::PrintParams params;
const printing::PrintSettings &settings = print_context_.settings(); const printing::PrintSettings &settings = print_context_.settings();
settings.RenderParams(&params); settings.RenderParams(&params);
// The dbi will be 0 if no default printer is configured. // The dbi will be 0 if no default printer is configured.
if(params.dpi == 0) if(params.dpi == 0)
return 0; return 0;
int page_count = 0; int page_count = 0;
gfx::Size canvas_size; gfx::Size canvas_size;
canvas_size.set_width( canvas_size.set_width(
printing::ConvertUnit( printing::ConvertUnit(
settings.page_setup_pixels().content_area().width(), settings.page_setup_pixels().content_area().width(),
static_cast<int>(params.dpi), static_cast<int>(params.dpi),
params.desired_dpi)); params.desired_dpi));
canvas_size.set_height( canvas_size.set_height(
printing::ConvertUnit( printing::ConvertUnit(
settings.page_setup_pixels().content_area().height(), settings.page_setup_pixels().content_area().height(),
static_cast<int>(params.dpi), static_cast<int>(params.dpi),
params.desired_dpi)); params.desired_dpi));
page_count = frame->printBegin(WebSize(canvas_size)); page_count = frame->printBegin(WebSize(canvas_size));
frame->printEnd(); frame->printEnd();
return page_count; return page_count;
} }

View File

@ -1,241 +1,241 @@
// Copyright (c) 2008 The Chromium Embedded Framework Authors. // Copyright (c) 2008 The Chromium Embedded Framework Authors.
// Portions copyright (c) 2006-2008 The Chromium Authors. All rights reserved. // Portions copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "browser_navigation_controller.h" #include "browser_navigation_controller.h"
#include "browser_impl.h" #include "browser_impl.h"
#include "base/logging.h" #include "base/logging.h"
#include "net/base/upload_data.h" #include "net/base/upload_data.h"
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// BrowserNavigationEntry // BrowserNavigationEntry
BrowserNavigationEntry::BrowserNavigationEntry() BrowserNavigationEntry::BrowserNavigationEntry()
: page_id_(-1) { : page_id_(-1) {
} }
BrowserNavigationEntry::BrowserNavigationEntry(int page_id, BrowserNavigationEntry::BrowserNavigationEntry(int page_id,
const GURL& url, const GURL& url,
const std::wstring& title, const std::wstring& title,
const std::wstring& target_frame, const std::wstring& target_frame,
const std::wstring& method, const std::wstring& method,
const WebKit::WebHTTPBody& upload, const WebKit::WebHTTPBody& upload,
const CefRequest::HeaderMap& headers) const CefRequest::HeaderMap& headers)
: page_id_(page_id), : page_id_(page_id),
url_(url), url_(url),
title_(title), title_(title),
target_frame_(target_frame), target_frame_(target_frame),
method_(method), method_(method),
headers_(headers) { headers_(headers) {
if(!upload.isNull()) if(!upload.isNull())
upload_ = upload; upload_ = upload;
} }
BrowserNavigationEntry::~BrowserNavigationEntry() { BrowserNavigationEntry::~BrowserNavigationEntry() {
} }
void BrowserNavigationEntry::SetContentState(const std::string& state) { void BrowserNavigationEntry::SetContentState(const std::string& state) {
state_ = state; state_ = state;
} }
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// BrowserNavigationController // BrowserNavigationController
BrowserNavigationController::BrowserNavigationController(CefBrowserImpl* shell) BrowserNavigationController::BrowserNavigationController(CefBrowserImpl* shell)
: pending_entry_(NULL), : pending_entry_(NULL),
last_committed_entry_index_(-1), last_committed_entry_index_(-1),
pending_entry_index_(-1), pending_entry_index_(-1),
browser_(shell), browser_(shell),
max_page_id_(-1) { max_page_id_(-1) {
} }
BrowserNavigationController::~BrowserNavigationController() { BrowserNavigationController::~BrowserNavigationController() {
DiscardPendingEntry(); DiscardPendingEntry();
} }
void BrowserNavigationController::Reset() { void BrowserNavigationController::Reset() {
entries_.clear(); entries_.clear();
DiscardPendingEntry(); DiscardPendingEntry();
last_committed_entry_index_ = -1; last_committed_entry_index_ = -1;
} }
void BrowserNavigationController::Reload(bool ignoreCache) { void BrowserNavigationController::Reload(bool ignoreCache) {
// Base the navigation on where we are now... // Base the navigation on where we are now...
int current_index = GetCurrentEntryIndex(); int current_index = GetCurrentEntryIndex();
// If we are no where, then we can't reload. TODO(darin): We should add a // If we are no where, then we can't reload. TODO(darin): We should add a
// CanReload method. // CanReload method.
if (current_index == -1) if (current_index == -1)
return; return;
DiscardPendingEntry(); DiscardPendingEntry();
pending_entry_index_ = current_index; pending_entry_index_ = current_index;
NavigateToPendingEntry(true, ignoreCache); NavigateToPendingEntry(true, ignoreCache);
} }
void BrowserNavigationController::GoToOffset(int offset) { void BrowserNavigationController::GoToOffset(int offset) {
int index = last_committed_entry_index_ + offset; int index = last_committed_entry_index_ + offset;
if (index < 0 || index >= GetEntryCount()) if (index < 0 || index >= GetEntryCount())
return; return;
GoToIndex(index); GoToIndex(index);
} }
void BrowserNavigationController::GoToIndex(int index) { void BrowserNavigationController::GoToIndex(int index) {
DCHECK(index >= 0); DCHECK(index >= 0);
DCHECK(index < static_cast<int>(entries_.size())); DCHECK(index < static_cast<int>(entries_.size()));
DiscardPendingEntry(); DiscardPendingEntry();
pending_entry_index_ = index; pending_entry_index_ = index;
NavigateToPendingEntry(false, false); NavigateToPendingEntry(false, false);
} }
void BrowserNavigationController::LoadEntry(BrowserNavigationEntry* entry) { void BrowserNavigationController::LoadEntry(BrowserNavigationEntry* entry) {
// When navigating to a new page, we don't know for sure if we will actually // When navigating to a new page, we don't know for sure if we will actually
// end up leaving the current page. The new page load could for example // end up leaving the current page. The new page load could for example
// result in a download or a 'no content' response (e.g., a mailto: URL). // result in a download or a 'no content' response (e.g., a mailto: URL).
DiscardPendingEntry(); DiscardPendingEntry();
pending_entry_ = entry; pending_entry_ = entry;
NavigateToPendingEntry(false, false); NavigateToPendingEntry(false, false);
} }
BrowserNavigationEntry* BrowserNavigationController::GetLastCommittedEntry() const { BrowserNavigationEntry* BrowserNavigationController::GetLastCommittedEntry() const {
if (last_committed_entry_index_ == -1) if (last_committed_entry_index_ == -1)
return NULL; return NULL;
return entries_[last_committed_entry_index_].get(); return entries_[last_committed_entry_index_].get();
} }
BrowserNavigationEntry* BrowserNavigationController::GetActiveEntry() const { BrowserNavigationEntry* BrowserNavigationController::GetActiveEntry() const {
BrowserNavigationEntry* entry = pending_entry_; BrowserNavigationEntry* entry = pending_entry_;
if (!entry) if (!entry)
entry = GetLastCommittedEntry(); entry = GetLastCommittedEntry();
return entry; return entry;
} }
int BrowserNavigationController::GetCurrentEntryIndex() const { int BrowserNavigationController::GetCurrentEntryIndex() const {
if (pending_entry_index_ != -1) if (pending_entry_index_ != -1)
return pending_entry_index_; return pending_entry_index_;
return last_committed_entry_index_; return last_committed_entry_index_;
} }
BrowserNavigationEntry* BrowserNavigationController::GetEntryAtIndex( BrowserNavigationEntry* BrowserNavigationController::GetEntryAtIndex(
int index) const { int index) const {
if (index < 0 || index >= GetEntryCount()) if (index < 0 || index >= GetEntryCount())
return NULL; return NULL;
return entries_[index].get(); return entries_[index].get();
} }
BrowserNavigationEntry* BrowserNavigationController::GetEntryWithPageID( BrowserNavigationEntry* BrowserNavigationController::GetEntryWithPageID(
int32 page_id) const { int32 page_id) const {
int index = GetEntryIndexWithPageID(page_id); int index = GetEntryIndexWithPageID(page_id);
return (index != -1) ? entries_[index].get() : NULL; return (index != -1) ? entries_[index].get() : NULL;
} }
void BrowserNavigationController::DidNavigateToEntry(BrowserNavigationEntry* entry) { void BrowserNavigationController::DidNavigateToEntry(BrowserNavigationEntry* entry) {
// If the entry is that of a page with PageID larger than any this Tab has // If the entry is that of a page with PageID larger than any this Tab has
// seen before, then consider it a new navigation. // seen before, then consider it a new navigation.
if (entry->GetPageID() > GetMaxPageID()) { if (entry->GetPageID() > GetMaxPageID()) {
InsertEntry(entry); InsertEntry(entry);
return; return;
} }
// Otherwise, we just need to update an existing entry with matching PageID. // Otherwise, we just need to update an existing entry with matching PageID.
// If the existing entry corresponds to the entry which is pending, then we // If the existing entry corresponds to the entry which is pending, then we
// must update the current entry index accordingly. When navigating to the // must update the current entry index accordingly. When navigating to the
// same URL, a new PageID is not created. // same URL, a new PageID is not created.
int existing_entry_index = GetEntryIndexWithPageID(entry->GetPageID()); int existing_entry_index = GetEntryIndexWithPageID(entry->GetPageID());
BrowserNavigationEntry* existing_entry = (existing_entry_index != -1) ? BrowserNavigationEntry* existing_entry = (existing_entry_index != -1) ?
entries_[existing_entry_index].get() : NULL; entries_[existing_entry_index].get() : NULL;
if (!existing_entry) { if (!existing_entry) {
// No existing entry, then simply ignore this navigation! // No existing entry, then simply ignore this navigation!
DLOG(WARNING) << "ignoring navigation for page: " << entry->GetPageID(); DLOG(WARNING) << "ignoring navigation for page: " << entry->GetPageID();
} else if (existing_entry == pending_entry_) { } else if (existing_entry == pending_entry_) {
// The given entry might provide a new URL... e.g., navigating back to a // The given entry might provide a new URL... e.g., navigating back to a
// page in session history could have resulted in a new client redirect. // page in session history could have resulted in a new client redirect.
existing_entry->SetURL(entry->GetURL()); existing_entry->SetURL(entry->GetURL());
existing_entry->SetContentState(entry->GetContentState()); existing_entry->SetContentState(entry->GetContentState());
last_committed_entry_index_ = pending_entry_index_; last_committed_entry_index_ = pending_entry_index_;
pending_entry_index_ = -1; pending_entry_index_ = -1;
pending_entry_ = NULL; pending_entry_ = NULL;
} else if (pending_entry_ && pending_entry_->GetPageID() == -1 && } else if (pending_entry_ && pending_entry_->GetPageID() == -1 &&
pending_entry_->GetURL() == existing_entry->GetURL()) { pending_entry_->GetURL() == existing_entry->GetURL()) {
// Not a new navigation // Not a new navigation
DiscardPendingEntry(); DiscardPendingEntry();
} else { } else {
// The given entry might provide a new URL... e.g., navigating to a page // The given entry might provide a new URL... e.g., navigating to a page
// might result in a client redirect, which should override the URL of the // might result in a client redirect, which should override the URL of the
// existing entry. // existing entry.
existing_entry->SetURL(entry->GetURL()); existing_entry->SetURL(entry->GetURL());
existing_entry->SetContentState(entry->GetContentState()); existing_entry->SetContentState(entry->GetContentState());
// The navigation could have been issued by the renderer, so be sure that // The navigation could have been issued by the renderer, so be sure that
// we update our current index. // we update our current index.
last_committed_entry_index_ = existing_entry_index; last_committed_entry_index_ = existing_entry_index;
} }
delete entry; delete entry;
UpdateMaxPageID(); UpdateMaxPageID();
} }
void BrowserNavigationController::DiscardPendingEntry() { void BrowserNavigationController::DiscardPendingEntry() {
if (pending_entry_index_ == -1) if (pending_entry_index_ == -1)
delete pending_entry_; delete pending_entry_;
pending_entry_ = NULL; pending_entry_ = NULL;
pending_entry_index_ = -1; pending_entry_index_ = -1;
} }
void BrowserNavigationController::InsertEntry(BrowserNavigationEntry* entry) { void BrowserNavigationController::InsertEntry(BrowserNavigationEntry* entry) {
DiscardPendingEntry(); DiscardPendingEntry();
// Prune any entry which are in front of the current entry // Prune any entry which are in front of the current entry
int current_size = static_cast<int>(entries_.size()); int current_size = static_cast<int>(entries_.size());
if (current_size > 0) { if (current_size > 0) {
while (last_committed_entry_index_ < (current_size - 1)) { while (last_committed_entry_index_ < (current_size - 1)) {
entries_.pop_back(); entries_.pop_back();
current_size--; current_size--;
} }
} }
entries_.push_back(linked_ptr<BrowserNavigationEntry>(entry)); entries_.push_back(linked_ptr<BrowserNavigationEntry>(entry));
last_committed_entry_index_ = static_cast<int>(entries_.size()) - 1; last_committed_entry_index_ = static_cast<int>(entries_.size()) - 1;
UpdateMaxPageID(); UpdateMaxPageID();
} }
int BrowserNavigationController::GetEntryIndexWithPageID(int32 page_id) const { int BrowserNavigationController::GetEntryIndexWithPageID(int32 page_id) const {
for (int i = static_cast<int>(entries_.size())-1; i >= 0; --i) { for (int i = static_cast<int>(entries_.size())-1; i >= 0; --i) {
if (entries_[i]->GetPageID() == page_id) if (entries_[i]->GetPageID() == page_id)
return i; return i;
} }
return -1; return -1;
} }
void BrowserNavigationController::NavigateToPendingEntry(bool reload, bool ignoreCache) { void BrowserNavigationController::NavigateToPendingEntry(bool reload, bool ignoreCache) {
// For session history navigations only the pending_entry_index_ is set. // For session history navigations only the pending_entry_index_ is set.
if (!pending_entry_) { if (!pending_entry_) {
DCHECK(pending_entry_index_ != -1); DCHECK(pending_entry_index_ != -1);
pending_entry_ = entries_[pending_entry_index_].get(); pending_entry_ = entries_[pending_entry_index_].get();
} }
if (browser_->UIT_Navigate(*pending_entry_, reload, ignoreCache)) { if (browser_->UIT_Navigate(*pending_entry_, reload, ignoreCache)) {
// Note: this is redundant if navigation completed synchronously because // Note: this is redundant if navigation completed synchronously because
// DidNavigateToEntry call this as well. // DidNavigateToEntry call this as well.
UpdateMaxPageID(); UpdateMaxPageID();
} else { } else {
DiscardPendingEntry(); DiscardPendingEntry();
} }
} }
void BrowserNavigationController::UpdateMaxPageID() { void BrowserNavigationController::UpdateMaxPageID() {
BrowserNavigationEntry* entry = GetActiveEntry(); BrowserNavigationEntry* entry = GetActiveEntry();
if (entry) if (entry)
max_page_id_ = std::max(max_page_id_, entry->GetPageID()); max_page_id_ = std::max(max_page_id_, entry->GetPageID());
} }

View File

@ -1,212 +1,212 @@
// Copyright (c) 2008-2009 The Chromium Embedded Framework Authors. // Copyright (c) 2008-2009 The Chromium Embedded Framework Authors.
// Portions copyright (c) 2006-2008 The Chromium Authors. All rights reserved. // Portions copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef _BROWSER_NAVIGATION_CONTROLLER_H #ifndef _BROWSER_NAVIGATION_CONTROLLER_H
#define _BROWSER_NAVIGATION_CONTROLLER_H #define _BROWSER_NAVIGATION_CONTROLLER_H
#include <string> #include <string>
#include <vector> #include <vector>
#include "base/basictypes.h" #include "base/basictypes.h"
#include "base/linked_ptr.h" #include "base/linked_ptr.h"
#include "base/ref_counted.h" #include "base/ref_counted.h"
#include "googleurl/src/gurl.h" #include "googleurl/src/gurl.h"
#include "third_party/WebKit/WebKit/chromium/public/WebDataSource.h" #include "third_party/WebKit/WebKit/chromium/public/WebDataSource.h"
#include "third_party/WebKit/WebKit/chromium/public/WebHTTPBody.h" #include "third_party/WebKit/WebKit/chromium/public/WebHTTPBody.h"
#include "include/cef.h" #include "include/cef.h"
class GURL; class GURL;
class CefBrowserImpl; class CefBrowserImpl;
// Associated with browser-initated navigations to hold tracking data. // Associated with browser-initated navigations to hold tracking data.
class BrowserExtraData : public WebKit::WebDataSource::ExtraData { class BrowserExtraData : public WebKit::WebDataSource::ExtraData {
public: public:
BrowserExtraData(int32 pending_page_id) BrowserExtraData(int32 pending_page_id)
: pending_page_id(pending_page_id), : pending_page_id(pending_page_id),
request_committed(false) { request_committed(false) {
} }
// Contains the page_id for this navigation or -1 if there is none yet. // Contains the page_id for this navigation or -1 if there is none yet.
int32 pending_page_id; int32 pending_page_id;
// True if we have already processed the "DidCommitLoad" event for this // True if we have already processed the "DidCommitLoad" event for this
// request. Used by session history. // request. Used by session history.
bool request_committed; bool request_committed;
}; };
// Stores one back/forward navigation state for the test shell. // Stores one back/forward navigation state for the test shell.
class BrowserNavigationEntry { class BrowserNavigationEntry {
public: public:
BrowserNavigationEntry(); BrowserNavigationEntry();
BrowserNavigationEntry(int page_id, BrowserNavigationEntry(int page_id,
const GURL& url, const GURL& url,
const std::wstring& title, const std::wstring& title,
const std::wstring& target_frame, const std::wstring& target_frame,
const std::wstring& method, const std::wstring& method,
const WebKit::WebHTTPBody& upload, const WebKit::WebHTTPBody& upload,
const CefRequest::HeaderMap& headers); const CefRequest::HeaderMap& headers);
~BrowserNavigationEntry(); ~BrowserNavigationEntry();
// Set / Get the URI // Set / Get the URI
void SetURL(const GURL& url) { url_ = url; } void SetURL(const GURL& url) { url_ = url; }
const GURL& GetURL() const { return url_; } const GURL& GetURL() const { return url_; }
// Set / Get the title // Set / Get the title
void SetTitle(const std::wstring& a_title) { title_ = a_title; } void SetTitle(const std::wstring& a_title) { title_ = a_title; }
const std::wstring& GetTitle() const { return title_; } const std::wstring& GetTitle() const { return title_; }
// Set / Get opaque state. // Set / Get opaque state.
// WARNING: This state is saved to the database and used to restore previous // WARNING: This state is saved to the database and used to restore previous
// states. If you use write a custom TabContents and provide your own // states. If you use write a custom TabContents and provide your own
// state make sure you have the ability to modify the format in the future // state make sure you have the ability to modify the format in the future
// while being able to deal with older versions. // while being able to deal with older versions.
void SetContentState(const std::string& state); void SetContentState(const std::string& state);
const std::string& GetContentState() const { return state_; } const std::string& GetContentState() const { return state_; }
// Get the page id corresponding to the tab's state. // Get the page id corresponding to the tab's state.
void SetPageID(int page_id) { page_id_ = page_id; } void SetPageID(int page_id) { page_id_ = page_id; }
int32 GetPageID() const { return page_id_; } int32 GetPageID() const { return page_id_; }
const std::wstring& GetTargetFrame() const { return target_frame_; } const std::wstring& GetTargetFrame() const { return target_frame_; }
const std::wstring& GetMethod() const { return method_; } const std::wstring& GetMethod() const { return method_; }
const WebKit::WebHTTPBody& GetUploadData() const { return upload_; } const WebKit::WebHTTPBody& GetUploadData() const { return upload_; }
const CefRequest::HeaderMap& GetHeaders() const { return headers_; } const CefRequest::HeaderMap& GetHeaders() const { return headers_; }
private: private:
// Describes the current page that the tab represents. This is not relevant // Describes the current page that the tab represents. This is not relevant
// for all tab contents types. // for all tab contents types.
int32 page_id_; int32 page_id_;
GURL url_; GURL url_;
std::wstring title_; std::wstring title_;
std::string state_; std::string state_;
std::wstring method_; std::wstring method_;
WebKit::WebHTTPBody upload_; WebKit::WebHTTPBody upload_;
CefRequest::HeaderMap headers_; CefRequest::HeaderMap headers_;
std::wstring target_frame_; std::wstring target_frame_;
DISALLOW_COPY_AND_ASSIGN(BrowserNavigationEntry); DISALLOW_COPY_AND_ASSIGN(BrowserNavigationEntry);
}; };
// Browser's NavigationController. The goal is to be as close to the Chrome // Browser's NavigationController. The goal is to be as close to the Chrome
// version as possible. // version as possible.
class BrowserNavigationController { class BrowserNavigationController {
public: public:
BrowserNavigationController(CefBrowserImpl* shell); BrowserNavigationController(CefBrowserImpl* shell);
~BrowserNavigationController(); ~BrowserNavigationController();
void Reset(); void Reset();
// Causes the controller to reload the current (or pending) entry. // Causes the controller to reload the current (or pending) entry.
void Reload(bool ignoreCache); void Reload(bool ignoreCache);
// Causes the controller to go to the specified offset from current. Does // Causes the controller to go to the specified offset from current. Does
// nothing if out of bounds. // nothing if out of bounds.
void GoToOffset(int offset); void GoToOffset(int offset);
// Causes the controller to go to the specified index. // Causes the controller to go to the specified index.
void GoToIndex(int index); void GoToIndex(int index);
// Causes the controller to load the specified entry. The controller // Causes the controller to load the specified entry. The controller
// assumes ownership of the entry. // assumes ownership of the entry.
// NOTE: Do not pass an entry that the controller already owns! // NOTE: Do not pass an entry that the controller already owns!
void LoadEntry(BrowserNavigationEntry* entry); void LoadEntry(BrowserNavigationEntry* entry);
// Returns the last committed entry, which may be null if there are no // Returns the last committed entry, which may be null if there are no
// committed entries. // committed entries.
BrowserNavigationEntry* GetLastCommittedEntry() const; BrowserNavigationEntry* GetLastCommittedEntry() const;
// Returns the number of entries in the NavigationControllerBase, excluding // Returns the number of entries in the NavigationControllerBase, excluding
// the pending entry if there is one. // the pending entry if there is one.
int GetEntryCount() const { int GetEntryCount() const {
return static_cast<int>(entries_.size()); return static_cast<int>(entries_.size());
} }
// Returns the active entry, which is the pending entry if a navigation is in // Returns the active entry, which is the pending entry if a navigation is in
// progress or the last committed entry otherwise. NOTE: This can be NULL!! // progress or the last committed entry otherwise. NOTE: This can be NULL!!
// //
// If you are trying to get the current state of the NavigationControllerBase, // If you are trying to get the current state of the NavigationControllerBase,
// this is the method you will typically want to call. // this is the method you will typically want to call.
BrowserNavigationEntry* GetActiveEntry() const; BrowserNavigationEntry* GetActiveEntry() const;
// Returns the index from which we would go back/forward or reload. This is // Returns the index from which we would go back/forward or reload. This is
// the last_committed_entry_index_ if pending_entry_index_ is -1. Otherwise, // the last_committed_entry_index_ if pending_entry_index_ is -1. Otherwise,
// it is the pending_entry_index_. // it is the pending_entry_index_.
int GetCurrentEntryIndex() const; int GetCurrentEntryIndex() const;
// Returns the entry at the specified index. Returns NULL if out of // Returns the entry at the specified index. Returns NULL if out of
// bounds. // bounds.
BrowserNavigationEntry* GetEntryAtIndex(int index) const; BrowserNavigationEntry* GetEntryAtIndex(int index) const;
// Return the entry with the corresponding type and page_id, or NULL if // Return the entry with the corresponding type and page_id, or NULL if
// not found. // not found.
BrowserNavigationEntry* GetEntryWithPageID(int32 page_id) const; BrowserNavigationEntry* GetEntryWithPageID(int32 page_id) const;
// Returns the index of the last committed entry. // Returns the index of the last committed entry.
int GetLastCommittedEntryIndex() const { int GetLastCommittedEntryIndex() const {
return last_committed_entry_index_; return last_committed_entry_index_;
} }
// Returns true if there are no entries before the last committed entry. // Returns true if there are no entries before the last committed entry.
bool IsAtStart() const { bool IsAtStart() const {
return (GetLastCommittedEntryIndex() == 0); return (GetLastCommittedEntryIndex() == 0);
} }
// Returns true if there are no entries after the last committed entry. // Returns true if there are no entries after the last committed entry.
bool IsAtEnd() const { bool IsAtEnd() const {
return (GetLastCommittedEntryIndex() == GetEntryCount()-1); return (GetLastCommittedEntryIndex() == GetEntryCount()-1);
} }
// Used to inform us of a navigation being committed for a tab. We will take // Used to inform us of a navigation being committed for a tab. We will take
// ownership of the entry. Any entry located forward to the current entry will // ownership of the entry. Any entry located forward to the current entry will
// be deleted. The new entry becomes the current entry. // be deleted. The new entry becomes the current entry.
void DidNavigateToEntry(BrowserNavigationEntry* entry); void DidNavigateToEntry(BrowserNavigationEntry* entry);
// Used to inform us to discard its pending entry. // Used to inform us to discard its pending entry.
void DiscardPendingEntry(); void DiscardPendingEntry();
private: private:
// Inserts an entry after the current position, removing all entries after it. // Inserts an entry after the current position, removing all entries after it.
// The new entry will become the active one. // The new entry will become the active one.
void InsertEntry(BrowserNavigationEntry* entry); void InsertEntry(BrowserNavigationEntry* entry);
int GetMaxPageID() const { return max_page_id_; } int GetMaxPageID() const { return max_page_id_; }
void NavigateToPendingEntry(bool reload, bool ignoreCache); void NavigateToPendingEntry(bool reload, bool ignoreCache);
// Return the index of the entry with the corresponding type and page_id, // Return the index of the entry with the corresponding type and page_id,
// or -1 if not found. // or -1 if not found.
int GetEntryIndexWithPageID(int32 page_id) const; int GetEntryIndexWithPageID(int32 page_id) const;
// Updates the max page ID with that of the given entry, if is larger. // Updates the max page ID with that of the given entry, if is larger.
void UpdateMaxPageID(); void UpdateMaxPageID();
// List of NavigationEntry for this tab // List of NavigationEntry for this tab
typedef std::vector< linked_ptr<BrowserNavigationEntry> > NavigationEntryList; typedef std::vector< linked_ptr<BrowserNavigationEntry> > NavigationEntryList;
typedef NavigationEntryList::iterator NavigationEntryListIterator; typedef NavigationEntryList::iterator NavigationEntryListIterator;
NavigationEntryList entries_; NavigationEntryList entries_;
// An entry we haven't gotten a response for yet. This will be discarded // An entry we haven't gotten a response for yet. This will be discarded
// when we navigate again. It's used only so we know what the currently // when we navigate again. It's used only so we know what the currently
// displayed tab is. // displayed tab is.
BrowserNavigationEntry* pending_entry_; BrowserNavigationEntry* pending_entry_;
// currently visible entry // currently visible entry
int last_committed_entry_index_; int last_committed_entry_index_;
// index of pending entry if it is in entries_, or -1 if pending_entry_ is a // index of pending entry if it is in entries_, or -1 if pending_entry_ is a
// new entry (created by LoadURL). // new entry (created by LoadURL).
int pending_entry_index_; int pending_entry_index_;
CefBrowserImpl* browser_; CefBrowserImpl* browser_;
int max_page_id_; int max_page_id_;
DISALLOW_EVIL_CONSTRUCTORS(BrowserNavigationController); DISALLOW_EVIL_CONSTRUCTORS(BrowserNavigationController);
}; };
#endif // _BROWSER_NAVIGATION_CONTROLLER_H #endif // _BROWSER_NAVIGATION_CONTROLLER_H

View File

@ -1,94 +1,94 @@
// Copyright (c) 2008 The Chromium Embedded Framework Authors. // Copyright (c) 2008 The Chromium Embedded Framework Authors.
// Portions copyright (c) 2006-2008 The Chromium Authors. All rights reserved. // Portions copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "browser_request_context.h" #include "browser_request_context.h"
#include "browser_resource_loader_bridge.h" #include "browser_resource_loader_bridge.h"
#include "build/build_config.h" #include "build/build_config.h"
#include "base/file_path.h" #include "base/file_path.h"
#include "net/base/cookie_monster.h" #include "net/base/cookie_monster.h"
#include "net/base/host_resolver.h" #include "net/base/host_resolver.h"
#include "net/base/ssl_config_service.h" #include "net/base/ssl_config_service.h"
#include "net/base/static_cookie_policy.h" #include "net/base/static_cookie_policy.h"
#include "net/ftp/ftp_network_layer.h" #include "net/ftp/ftp_network_layer.h"
#include "net/http/http_auth_handler_factory.h" #include "net/http/http_auth_handler_factory.h"
#include "net/proxy/proxy_config_service.h" #include "net/proxy/proxy_config_service.h"
#include "net/proxy/proxy_config_service_fixed.h" #include "net/proxy/proxy_config_service_fixed.h"
#include "net/proxy/proxy_service.h" #include "net/proxy/proxy_service.h"
#include "webkit/blob/blob_storage_controller.h" #include "webkit/blob/blob_storage_controller.h"
#include "webkit/glue/webkit_glue.h" #include "webkit/glue/webkit_glue.h"
BrowserRequestContext::BrowserRequestContext() { BrowserRequestContext::BrowserRequestContext() {
Init(FilePath(), net::HttpCache::NORMAL, false); Init(FilePath(), net::HttpCache::NORMAL, false);
} }
BrowserRequestContext::BrowserRequestContext( BrowserRequestContext::BrowserRequestContext(
const FilePath& cache_path, const FilePath& cache_path,
net::HttpCache::Mode cache_mode, net::HttpCache::Mode cache_mode,
bool no_proxy) { bool no_proxy) {
Init(cache_path, cache_mode, no_proxy); Init(cache_path, cache_mode, no_proxy);
} }
void BrowserRequestContext::Init( void BrowserRequestContext::Init(
const FilePath& cache_path, const FilePath& cache_path,
net::HttpCache::Mode cache_mode, net::HttpCache::Mode cache_mode,
bool no_proxy) { bool no_proxy) {
cookie_store_ = new net::CookieMonster(NULL, NULL); cookie_store_ = new net::CookieMonster(NULL, NULL);
cookie_policy_ = new net::StaticCookiePolicy(); cookie_policy_ = new net::StaticCookiePolicy();
// hard-code A-L and A-C for test shells // hard-code A-L and A-C for test shells
accept_language_ = "en-us,en"; accept_language_ = "en-us,en";
accept_charset_ = "iso-8859-1,*,utf-8"; accept_charset_ = "iso-8859-1,*,utf-8";
// Use the system proxy settings. // Use the system proxy settings.
scoped_ptr<net::ProxyConfigService> proxy_config_service( scoped_ptr<net::ProxyConfigService> proxy_config_service(
net::ProxyService::CreateSystemProxyConfigService( net::ProxyService::CreateSystemProxyConfigService(
MessageLoop::current(), NULL)); MessageLoop::current(), NULL));
host_resolver_ = host_resolver_ =
net::CreateSystemHostResolver(net::HostResolver::kDefaultParallelism, net::CreateSystemHostResolver(net::HostResolver::kDefaultParallelism,
NULL); NULL);
proxy_service_ = net::ProxyService::Create(proxy_config_service.release(), proxy_service_ = net::ProxyService::Create(proxy_config_service.release(),
false, NULL, NULL, NULL, NULL); false, NULL, NULL, NULL, NULL);
ssl_config_service_ = net::SSLConfigService::CreateSystemSSLConfigService(); ssl_config_service_ = net::SSLConfigService::CreateSystemSSLConfigService();
http_auth_handler_factory_ = http_auth_handler_factory_ =
net::HttpAuthHandlerFactory::CreateDefault(host_resolver_); net::HttpAuthHandlerFactory::CreateDefault(host_resolver_);
net::HttpCache::DefaultBackend* backend = new net::HttpCache::DefaultBackend( net::HttpCache::DefaultBackend* backend = new net::HttpCache::DefaultBackend(
cache_path.empty() ? net::MEMORY_CACHE : net::DISK_CACHE, cache_path.empty() ? net::MEMORY_CACHE : net::DISK_CACHE,
cache_path, 0, BrowserResourceLoaderBridge::GetCacheThread()); cache_path, 0, BrowserResourceLoaderBridge::GetCacheThread());
net::HttpCache* cache = net::HttpCache* cache =
new net::HttpCache(host_resolver_, proxy_service_, ssl_config_service_, new net::HttpCache(host_resolver_, proxy_service_, ssl_config_service_,
http_auth_handler_factory_, NULL, NULL, backend); http_auth_handler_factory_, NULL, NULL, backend);
cache->set_mode(cache_mode); cache->set_mode(cache_mode);
http_transaction_factory_ = cache; http_transaction_factory_ = cache;
ftp_transaction_factory_ = new net::FtpNetworkLayer(host_resolver_); ftp_transaction_factory_ = new net::FtpNetworkLayer(host_resolver_);
blob_storage_controller_.reset(new webkit_blob::BlobStorageController()); blob_storage_controller_.reset(new webkit_blob::BlobStorageController());
} }
BrowserRequestContext::~BrowserRequestContext() { BrowserRequestContext::~BrowserRequestContext() {
delete ftp_transaction_factory_; delete ftp_transaction_factory_;
delete http_transaction_factory_; delete http_transaction_factory_;
delete http_auth_handler_factory_; delete http_auth_handler_factory_;
delete static_cast<net::StaticCookiePolicy*>(cookie_policy_); delete static_cast<net::StaticCookiePolicy*>(cookie_policy_);
delete host_resolver_; delete host_resolver_;
} }
void BrowserRequestContext::SetAcceptAllCookies(bool accept_all_cookies) { void BrowserRequestContext::SetAcceptAllCookies(bool accept_all_cookies) {
net::StaticCookiePolicy::Type policy_type = accept_all_cookies ? net::StaticCookiePolicy::Type policy_type = accept_all_cookies ?
net::StaticCookiePolicy::ALLOW_ALL_COOKIES : net::StaticCookiePolicy::ALLOW_ALL_COOKIES :
net::StaticCookiePolicy::BLOCK_THIRD_PARTY_COOKIES; net::StaticCookiePolicy::BLOCK_THIRD_PARTY_COOKIES;
static_cast<net::StaticCookiePolicy*>(cookie_policy())->set_type(policy_type); static_cast<net::StaticCookiePolicy*>(cookie_policy())->set_type(policy_type);
} }
const std::string& BrowserRequestContext::GetUserAgent( const std::string& BrowserRequestContext::GetUserAgent(
const GURL& url) const { const GURL& url) const {
return webkit_glue::GetUserAgent(url); return webkit_glue::GetUserAgent(url);
} }

View File

@ -1,46 +1,46 @@
// Copyright (c) 2008 The Chromium Embedded Framework Authors. // Copyright (c) 2008 The Chromium Embedded Framework Authors.
// Portions copyright (c) 2006-2008 The Chromium Authors. All rights reserved. // Portions copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef _BROWSER_REQUEST_CONTEXT_H #ifndef _BROWSER_REQUEST_CONTEXT_H
#define _BROWSER_REQUEST_CONTEXT_H #define _BROWSER_REQUEST_CONTEXT_H
#include "net/http/http_cache.h" #include "net/http/http_cache.h"
#include "net/url_request/url_request_context.h" #include "net/url_request/url_request_context.h"
class FilePath; class FilePath;
namespace webkit_blob { namespace webkit_blob {
class BlobStorageController; class BlobStorageController;
} }
// A basic URLRequestContext that only provides an in-memory cookie store. // A basic URLRequestContext that only provides an in-memory cookie store.
class BrowserRequestContext : public URLRequestContext { class BrowserRequestContext : public URLRequestContext {
public: public:
// Use an in-memory cache // Use an in-memory cache
BrowserRequestContext(); BrowserRequestContext();
~BrowserRequestContext(); ~BrowserRequestContext();
// Use an on-disk cache at the specified location. Optionally, use the cache // Use an on-disk cache at the specified location. Optionally, use the cache
// in playback or record mode. // in playback or record mode.
BrowserRequestContext(const FilePath& cache_path, BrowserRequestContext(const FilePath& cache_path,
net::HttpCache::Mode cache_mode, net::HttpCache::Mode cache_mode,
bool no_proxy); bool no_proxy);
virtual const std::string& GetUserAgent(const GURL& url) const; virtual const std::string& GetUserAgent(const GURL& url) const;
void SetAcceptAllCookies(bool accept_all_cookies); void SetAcceptAllCookies(bool accept_all_cookies);
webkit_blob::BlobStorageController* blob_storage_controller() const { webkit_blob::BlobStorageController* blob_storage_controller() const {
return blob_storage_controller_.get(); return blob_storage_controller_.get();
} }
private: private:
void Init(const FilePath& cache_path, net::HttpCache::Mode cache_mode, void Init(const FilePath& cache_path, net::HttpCache::Mode cache_mode,
bool no_proxy); bool no_proxy);
scoped_ptr<webkit_blob::BlobStorageController> blob_storage_controller_; scoped_ptr<webkit_blob::BlobStorageController> blob_storage_controller_;
}; };
#endif // _BROWSER_REQUEST_CONTEXT_H #endif // _BROWSER_REQUEST_CONTEXT_H

File diff suppressed because it is too large Load Diff

View File

@ -1,28 +1,28 @@
// Copyright (c) 2008 The Chromium Embedded Framework Authors. // Copyright (c) 2008 The Chromium Embedded Framework Authors.
// Portions copyright (c) 2006-2008 The Chromium Authors. All rights reserved. // Portions copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef _BROWSER_RESOURCE_LOADER_BRIDGE_H #ifndef _BROWSER_RESOURCE_LOADER_BRIDGE_H
#define _BROWSER_RESOURCE_LOADER_BRIDGE_H #define _BROWSER_RESOURCE_LOADER_BRIDGE_H
#include <string> #include <string>
#include "base/message_loop_proxy.h" #include "base/message_loop_proxy.h"
class GURL; class GURL;
class BrowserResourceLoaderBridge { class BrowserResourceLoaderBridge {
public: public:
// May only be called after Init. // May only be called after Init.
static void SetCookie(const GURL& url, static void SetCookie(const GURL& url,
const GURL& first_party_for_cookies, const GURL& first_party_for_cookies,
const std::string& cookie); const std::string& cookie);
static std::string GetCookies(const GURL& url, static std::string GetCookies(const GURL& url,
const GURL& first_party_for_cookies); const GURL& first_party_for_cookies);
static void SetAcceptAllCookies(bool accept_all_cookies); static void SetAcceptAllCookies(bool accept_all_cookies);
static scoped_refptr<base::MessageLoopProxy> GetCacheThread(); static scoped_refptr<base::MessageLoopProxy> GetCacheThread();
}; };
#endif // _BROWSER_RESOURCE_LOADER_BRIDGE_H #endif // _BROWSER_RESOURCE_LOADER_BRIDGE_H

View File

@ -1,242 +1,242 @@
// Copyright (c) 2009 The Chromium Authors. All rights reserved. // Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include <vector> #include <vector>
#include "browser_socket_stream_bridge.h" #include "browser_socket_stream_bridge.h"
#include "base/message_loop.h" #include "base/message_loop.h"
#include "base/ref_counted.h" #include "base/ref_counted.h"
#include "googleurl/src/gurl.h" #include "googleurl/src/gurl.h"
#include "net/socket_stream/socket_stream_job.h" #include "net/socket_stream/socket_stream_job.h"
#include "net/websockets/websocket_job.h" #include "net/websockets/websocket_job.h"
#include "net/url_request/url_request_context.h" #include "net/url_request/url_request_context.h"
#include "webkit/glue/websocketstreamhandle_bridge.h" #include "webkit/glue/websocketstreamhandle_bridge.h"
#include "webkit/glue/websocketstreamhandle_delegate.h" #include "webkit/glue/websocketstreamhandle_delegate.h"
#include "third_party/WebKit/WebKit/chromium/public/WebSocketStreamHandle.h" #include "third_party/WebKit/WebKit/chromium/public/WebSocketStreamHandle.h"
using webkit_glue::WebSocketStreamHandleBridge; using webkit_glue::WebSocketStreamHandleBridge;
static const int kNoSocketId = 0; static const int kNoSocketId = 0;
namespace { namespace {
MessageLoop* g_io_thread; MessageLoop* g_io_thread;
scoped_refptr<URLRequestContext> g_request_context; scoped_refptr<URLRequestContext> g_request_context;
class WebSocketStreamHandleBridgeImpl class WebSocketStreamHandleBridgeImpl
: public WebSocketStreamHandleBridge, : public WebSocketStreamHandleBridge,
public net::SocketStream::Delegate { public net::SocketStream::Delegate {
public: public:
WebSocketStreamHandleBridgeImpl( WebSocketStreamHandleBridgeImpl(
WebKit::WebSocketStreamHandle* handle, WebKit::WebSocketStreamHandle* handle,
webkit_glue::WebSocketStreamHandleDelegate* delegate); webkit_glue::WebSocketStreamHandleDelegate* delegate);
// WebSocketStreamHandleBridge methods. // WebSocketStreamHandleBridge methods.
virtual void Connect(const GURL& url); virtual void Connect(const GURL& url);
virtual bool Send(const std::vector<char>& data); virtual bool Send(const std::vector<char>& data);
virtual void Close(); virtual void Close();
// net::SocketStream::Delegate methods. // net::SocketStream::Delegate methods.
virtual void OnConnected(net::SocketStream* req, virtual void OnConnected(net::SocketStream* req,
int max_pending_send_allowed); int max_pending_send_allowed);
virtual void OnSentData(net::SocketStream* req, virtual void OnSentData(net::SocketStream* req,
int amount_sent); int amount_sent);
virtual void OnReceivedData(net::SocketStream* req, virtual void OnReceivedData(net::SocketStream* req,
const char* data, int len); const char* data, int len);
virtual void OnClose(net::SocketStream* req); virtual void OnClose(net::SocketStream* req);
private: private:
virtual ~WebSocketStreamHandleBridgeImpl(); virtual ~WebSocketStreamHandleBridgeImpl();
// Runs on |g_io_thread|; // Runs on |g_io_thread|;
void DoConnect(const GURL& url); void DoConnect(const GURL& url);
void DoSend(std::vector<char>* data); void DoSend(std::vector<char>* data);
void DoClose(); void DoClose();
// Runs on |message_loop_|; // Runs on |message_loop_|;
void DoOnConnected(int max_amount_send_allowed); void DoOnConnected(int max_amount_send_allowed);
void DoOnSentData(int amount_sent); void DoOnSentData(int amount_sent);
void DoOnReceivedData(std::vector<char>* data); void DoOnReceivedData(std::vector<char>* data);
void DoOnClose(); void DoOnClose();
int socket_id_; int socket_id_;
MessageLoop* message_loop_; MessageLoop* message_loop_;
WebKit::WebSocketStreamHandle* handle_; WebKit::WebSocketStreamHandle* handle_;
webkit_glue::WebSocketStreamHandleDelegate* delegate_; webkit_glue::WebSocketStreamHandleDelegate* delegate_;
scoped_refptr<net::SocketStreamJob> socket_; scoped_refptr<net::SocketStreamJob> socket_;
// Number of pending tasks to handle net::SocketStream::Delegate methods. // Number of pending tasks to handle net::SocketStream::Delegate methods.
int num_pending_tasks_; int num_pending_tasks_;
DISALLOW_COPY_AND_ASSIGN(WebSocketStreamHandleBridgeImpl); DISALLOW_COPY_AND_ASSIGN(WebSocketStreamHandleBridgeImpl);
}; };
WebSocketStreamHandleBridgeImpl::WebSocketStreamHandleBridgeImpl( WebSocketStreamHandleBridgeImpl::WebSocketStreamHandleBridgeImpl(
WebKit::WebSocketStreamHandle* handle, WebKit::WebSocketStreamHandle* handle,
webkit_glue::WebSocketStreamHandleDelegate* delegate) webkit_glue::WebSocketStreamHandleDelegate* delegate)
: socket_id_(kNoSocketId), : socket_id_(kNoSocketId),
message_loop_(MessageLoop::current()), message_loop_(MessageLoop::current()),
handle_(handle), handle_(handle),
delegate_(delegate), delegate_(delegate),
num_pending_tasks_(0) { num_pending_tasks_(0) {
net::WebSocketJob::EnsureInit(); net::WebSocketJob::EnsureInit();
} }
WebSocketStreamHandleBridgeImpl::~WebSocketStreamHandleBridgeImpl() { WebSocketStreamHandleBridgeImpl::~WebSocketStreamHandleBridgeImpl() {
DCHECK_EQ(socket_id_, kNoSocketId); DCHECK_EQ(socket_id_, kNoSocketId);
} }
void WebSocketStreamHandleBridgeImpl::Connect(const GURL& url) { void WebSocketStreamHandleBridgeImpl::Connect(const GURL& url) {
DCHECK(g_io_thread); DCHECK(g_io_thread);
AddRef(); // Released in DoOnClose(). AddRef(); // Released in DoOnClose().
g_io_thread->PostTask( g_io_thread->PostTask(
FROM_HERE, FROM_HERE,
NewRunnableMethod(this, &WebSocketStreamHandleBridgeImpl::DoConnect, NewRunnableMethod(this, &WebSocketStreamHandleBridgeImpl::DoConnect,
url)); url));
if (delegate_) if (delegate_)
delegate_->WillOpenStream(handle_, url); delegate_->WillOpenStream(handle_, url);
} }
bool WebSocketStreamHandleBridgeImpl::Send( bool WebSocketStreamHandleBridgeImpl::Send(
const std::vector<char>& data) { const std::vector<char>& data) {
DCHECK(g_io_thread); DCHECK(g_io_thread);
g_io_thread->PostTask( g_io_thread->PostTask(
FROM_HERE, FROM_HERE,
NewRunnableMethod(this, &WebSocketStreamHandleBridgeImpl::DoSend, NewRunnableMethod(this, &WebSocketStreamHandleBridgeImpl::DoSend,
new std::vector<char>(data))); new std::vector<char>(data)));
return true; return true;
} }
void WebSocketStreamHandleBridgeImpl::Close() { void WebSocketStreamHandleBridgeImpl::Close() {
DCHECK(g_io_thread); DCHECK(g_io_thread);
g_io_thread->PostTask( g_io_thread->PostTask(
FROM_HERE, FROM_HERE,
NewRunnableMethod(this, &WebSocketStreamHandleBridgeImpl::DoClose)); NewRunnableMethod(this, &WebSocketStreamHandleBridgeImpl::DoClose));
} }
void WebSocketStreamHandleBridgeImpl::OnConnected( void WebSocketStreamHandleBridgeImpl::OnConnected(
net::SocketStream* socket, int max_pending_send_allowed) { net::SocketStream* socket, int max_pending_send_allowed) {
++num_pending_tasks_; ++num_pending_tasks_;
message_loop_->PostTask( message_loop_->PostTask(
FROM_HERE, FROM_HERE,
NewRunnableMethod(this, &WebSocketStreamHandleBridgeImpl::DoOnConnected, NewRunnableMethod(this, &WebSocketStreamHandleBridgeImpl::DoOnConnected,
max_pending_send_allowed)); max_pending_send_allowed));
} }
void WebSocketStreamHandleBridgeImpl::OnSentData( void WebSocketStreamHandleBridgeImpl::OnSentData(
net::SocketStream* socket, int amount_sent) { net::SocketStream* socket, int amount_sent) {
++num_pending_tasks_; ++num_pending_tasks_;
message_loop_->PostTask( message_loop_->PostTask(
FROM_HERE, FROM_HERE,
NewRunnableMethod(this, &WebSocketStreamHandleBridgeImpl::DoOnSentData, NewRunnableMethod(this, &WebSocketStreamHandleBridgeImpl::DoOnSentData,
amount_sent)); amount_sent));
} }
void WebSocketStreamHandleBridgeImpl::OnReceivedData( void WebSocketStreamHandleBridgeImpl::OnReceivedData(
net::SocketStream* socket, const char* data, int len) { net::SocketStream* socket, const char* data, int len) {
++num_pending_tasks_; ++num_pending_tasks_;
message_loop_->PostTask( message_loop_->PostTask(
FROM_HERE, FROM_HERE,
NewRunnableMethod(this, NewRunnableMethod(this,
&WebSocketStreamHandleBridgeImpl::DoOnReceivedData, &WebSocketStreamHandleBridgeImpl::DoOnReceivedData,
new std::vector<char>(data, data + len))); new std::vector<char>(data, data + len)));
} }
void WebSocketStreamHandleBridgeImpl::OnClose(net::SocketStream* socket) { void WebSocketStreamHandleBridgeImpl::OnClose(net::SocketStream* socket) {
++num_pending_tasks_; ++num_pending_tasks_;
// Release socket_ on IO thread. // Release socket_ on IO thread.
socket_ = NULL; socket_ = NULL;
socket_id_ = kNoSocketId; socket_id_ = kNoSocketId;
message_loop_->PostTask( message_loop_->PostTask(
FROM_HERE, FROM_HERE,
NewRunnableMethod(this, &WebSocketStreamHandleBridgeImpl::DoOnClose)); NewRunnableMethod(this, &WebSocketStreamHandleBridgeImpl::DoOnClose));
} }
void WebSocketStreamHandleBridgeImpl::DoConnect(const GURL& url) { void WebSocketStreamHandleBridgeImpl::DoConnect(const GURL& url) {
DCHECK(MessageLoop::current() == g_io_thread); DCHECK(MessageLoop::current() == g_io_thread);
socket_ = net::SocketStreamJob::CreateSocketStreamJob(url, this); socket_ = net::SocketStreamJob::CreateSocketStreamJob(url, this);
socket_->set_context(g_request_context); socket_->set_context(g_request_context);
socket_->Connect(); socket_->Connect();
} }
void WebSocketStreamHandleBridgeImpl::DoSend(std::vector<char>* data) { void WebSocketStreamHandleBridgeImpl::DoSend(std::vector<char>* data) {
DCHECK(MessageLoop::current() == g_io_thread); DCHECK(MessageLoop::current() == g_io_thread);
scoped_ptr<std::vector<char> > scoped_data(data); scoped_ptr<std::vector<char> > scoped_data(data);
if (!socket_) if (!socket_)
return; return;
if (!socket_->SendData(&(data->at(0)), data->size())) if (!socket_->SendData(&(data->at(0)), data->size()))
socket_->Close(); socket_->Close();
} }
void WebSocketStreamHandleBridgeImpl::DoClose() { void WebSocketStreamHandleBridgeImpl::DoClose() {
DCHECK(MessageLoop::current() == g_io_thread); DCHECK(MessageLoop::current() == g_io_thread);
if (!socket_) if (!socket_)
return; return;
socket_->Close(); socket_->Close();
} }
void WebSocketStreamHandleBridgeImpl::DoOnConnected( void WebSocketStreamHandleBridgeImpl::DoOnConnected(
int max_pending_send_allowed) { int max_pending_send_allowed) {
DCHECK(MessageLoop::current() == message_loop_); DCHECK(MessageLoop::current() == message_loop_);
--num_pending_tasks_; --num_pending_tasks_;
if (delegate_) if (delegate_)
delegate_->DidOpenStream(handle_, max_pending_send_allowed); delegate_->DidOpenStream(handle_, max_pending_send_allowed);
} }
void WebSocketStreamHandleBridgeImpl::DoOnSentData(int amount_sent) { void WebSocketStreamHandleBridgeImpl::DoOnSentData(int amount_sent) {
DCHECK(MessageLoop::current() == message_loop_); DCHECK(MessageLoop::current() == message_loop_);
--num_pending_tasks_; --num_pending_tasks_;
if (delegate_) if (delegate_)
delegate_->DidSendData(handle_, amount_sent); delegate_->DidSendData(handle_, amount_sent);
} }
void WebSocketStreamHandleBridgeImpl::DoOnReceivedData( void WebSocketStreamHandleBridgeImpl::DoOnReceivedData(
std::vector<char>* data) { std::vector<char>* data) {
DCHECK(MessageLoop::current() == message_loop_); DCHECK(MessageLoop::current() == message_loop_);
--num_pending_tasks_; --num_pending_tasks_;
scoped_ptr<std::vector<char> > scoped_data(data); scoped_ptr<std::vector<char> > scoped_data(data);
if (delegate_) if (delegate_)
delegate_->DidReceiveData(handle_, &(data->at(0)), data->size()); delegate_->DidReceiveData(handle_, &(data->at(0)), data->size());
} }
void WebSocketStreamHandleBridgeImpl::DoOnClose() { void WebSocketStreamHandleBridgeImpl::DoOnClose() {
DCHECK(MessageLoop::current() == message_loop_); DCHECK(MessageLoop::current() == message_loop_);
--num_pending_tasks_; --num_pending_tasks_;
// Don't handle OnClose if there are pending tasks. // Don't handle OnClose if there are pending tasks.
DCHECK_EQ(num_pending_tasks_, 0); DCHECK_EQ(num_pending_tasks_, 0);
DCHECK(!socket_); DCHECK(!socket_);
DCHECK_EQ(socket_id_, kNoSocketId); DCHECK_EQ(socket_id_, kNoSocketId);
webkit_glue::WebSocketStreamHandleDelegate* delegate = delegate_; webkit_glue::WebSocketStreamHandleDelegate* delegate = delegate_;
delegate_ = NULL; delegate_ = NULL;
if (delegate) if (delegate)
delegate->DidClose(handle_); delegate->DidClose(handle_);
Release(); Release();
} }
} // namespace } // namespace
/* static */ /* static */
void BrowserSocketStreamBridge::InitializeOnIOThread( void BrowserSocketStreamBridge::InitializeOnIOThread(
URLRequestContext* request_context) { URLRequestContext* request_context) {
g_io_thread = MessageLoop::current(); g_io_thread = MessageLoop::current();
g_request_context = request_context; g_request_context = request_context;
} }
void BrowserSocketStreamBridge::Cleanup() { void BrowserSocketStreamBridge::Cleanup() {
g_io_thread = NULL; g_io_thread = NULL;
g_request_context = NULL; g_request_context = NULL;
} }
namespace webkit_glue { namespace webkit_glue {
/* static */ /* static */
WebSocketStreamHandleBridge* WebSocketStreamHandleBridge::Create( WebSocketStreamHandleBridge* WebSocketStreamHandleBridge::Create(
WebKit::WebSocketStreamHandle* handle, WebKit::WebSocketStreamHandle* handle,
WebSocketStreamHandleDelegate* delegate) { WebSocketStreamHandleDelegate* delegate) {
return new WebSocketStreamHandleBridgeImpl(handle, delegate); return new WebSocketStreamHandleBridgeImpl(handle, delegate);
} }
} // namespace webkit_glue } // namespace webkit_glue

View File

@ -1,16 +1,16 @@
// Copyright (c) 2009 The Chromium Authors. All rights reserved. // Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef _BROWSER_SOCKET_STREAM_BRIDGE_H #ifndef _BROWSER_SOCKET_STREAM_BRIDGE_H
#define _BROWSER_SOCKET_STREAM_BRIDGE_H #define _BROWSER_SOCKET_STREAM_BRIDGE_H
class URLRequestContext; class URLRequestContext;
class BrowserSocketStreamBridge { class BrowserSocketStreamBridge {
public: public:
static void InitializeOnIOThread(URLRequestContext* request_context); static void InitializeOnIOThread(URLRequestContext* request_context);
static void Cleanup(); static void Cleanup();
}; };
#endif // _BROWSER_SOCKET_STREAM_BRIDGE_H #endif // _BROWSER_SOCKET_STREAM_BRIDGE_H

View File

@ -1,141 +1,141 @@
// Copyright (c) 2008-2009 The Chromium Embedded Framework Authors. // Copyright (c) 2008-2009 The Chromium Embedded Framework Authors.
// Portions copyright (c) 2006-2008 The Chromium Authors. All rights reserved. // Portions copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "base/compiler_specific.h" #include "base/compiler_specific.h"
#include "third_party/webkit/webcore/config.h" #include "third_party/webkit/webcore/config.h"
MSVC_PUSH_WARNING_LEVEL(0); MSVC_PUSH_WARNING_LEVEL(0);
#include "Cache.h" #include "Cache.h"
#include "TextEncoding.h" #include "TextEncoding.h"
#include "third_party/WebKit/WebKit/chromium/src/WebFrameImpl.h" #include "third_party/WebKit/WebKit/chromium/src/WebFrameImpl.h"
MSVC_POP_WARNING(); MSVC_POP_WARNING();
#include "browser_webkit_glue.h" #include "browser_webkit_glue.h"
#undef LOG #undef LOG
#include "base/logging.h" #include "base/logging.h"
#include "base/path_service.h" #include "base/path_service.h"
#include "base/scoped_ptr.h" #include "base/scoped_ptr.h"
#include "base/string16.h" #include "base/string16.h"
#include "base/utf_string_conversions.h" #include "base/utf_string_conversions.h"
#include "base/win_util.h" #include "base/win_util.h"
#include "net/base/mime_util.h" #include "net/base/mime_util.h"
#include "third_party/WebKit/WebKit/chromium/public/WebFrame.h" #include "third_party/WebKit/WebKit/chromium/public/WebFrame.h"
#include "third_party/WebKit/WebKit/chromium/public/WebString.h" #include "third_party/WebKit/WebKit/chromium/public/WebString.h"
#include "webkit/glue/webkit_glue.h" #include "webkit/glue/webkit_glue.h"
// Generated by GRIT // Generated by GRIT
#include "grit/webkit_resources.h" #include "grit/webkit_resources.h"
using WebKit::WebFrameImpl; using WebKit::WebFrameImpl;
namespace webkit_glue { namespace webkit_glue {
bool IsMediaPlayerAvailable() { bool IsMediaPlayerAvailable() {
return true; return true;
} }
void PrecacheUrl(const char16* url, int url_length) {} void PrecacheUrl(const char16* url, int url_length) {}
void AppendToLog(const char* file, int line, const char* msg) { void AppendToLog(const char* file, int line, const char* msg) {
logging::LogMessage(file, line).stream() << msg; logging::LogMessage(file, line).stream() << msg;
} }
base::StringPiece GetDataResource(int resource_id) { base::StringPiece GetDataResource(int resource_id) {
return NetResourceProvider(resource_id); return NetResourceProvider(resource_id);
} }
bool GetApplicationDirectory(FilePath* path) { bool GetApplicationDirectory(FilePath* path) {
return PathService::Get(base::DIR_EXE, path); return PathService::Get(base::DIR_EXE, path);
} }
bool GetExeDirectory(FilePath* path) { bool GetExeDirectory(FilePath* path) {
return PathService::Get(base::DIR_EXE, path); return PathService::Get(base::DIR_EXE, path);
} }
bool IsPluginRunningInRendererProcess() { bool IsPluginRunningInRendererProcess() {
return true; return true;
} }
bool GetPluginFinderURL(std::string* plugin_finder_url) { bool GetPluginFinderURL(std::string* plugin_finder_url) {
return false; return false;
} }
bool IsDefaultPluginEnabled() { bool IsDefaultPluginEnabled() {
return false; return false;
} }
bool IsProtocolSupportedForMedia(const GURL& url) { bool IsProtocolSupportedForMedia(const GURL& url) {
if (url.SchemeIsFile() || url.SchemeIs("http") || url.SchemeIs("https")) if (url.SchemeIsFile() || url.SchemeIs("http") || url.SchemeIs("https"))
return true; return true;
return false; return false;
} }
std::string GetWebKitLocale() { std::string GetWebKitLocale() {
return "en-US"; return "en-US";
} }
void InitializeTextEncoding() { void InitializeTextEncoding() {
WebCore::UTF8Encoding(); WebCore::UTF8Encoding();
} }
v8::Handle<v8::Context> GetV8Context(WebKit::WebFrame* frame) v8::Handle<v8::Context> GetV8Context(WebKit::WebFrame* frame)
{ {
WebFrameImpl* webFrameImpl = static_cast<WebFrameImpl*>(frame); WebFrameImpl* webFrameImpl = static_cast<WebFrameImpl*>(frame);
WebCore::Frame* core_frame = webFrameImpl->frame(); WebCore::Frame* core_frame = webFrameImpl->frame();
return WebCore::V8Proxy::context(core_frame); return WebCore::V8Proxy::context(core_frame);
} }
void CloseIdleConnections() { void CloseIdleConnections() {
// Used in benchmarking, Ignored for CEF. // Used in benchmarking, Ignored for CEF.
} }
void SetCacheMode(bool enabled) { void SetCacheMode(bool enabled) {
// Used in benchmarking, Ignored for CEF. // Used in benchmarking, Ignored for CEF.
} }
void ClearCache() void ClearCache()
{ {
// Clear the cache by disabling it and then re-enabling it. // Clear the cache by disabling it and then re-enabling it.
WebCore::cache()->setDisabled(true); WebCore::cache()->setDisabled(true);
WebCore::cache()->setDisabled(false); WebCore::cache()->setDisabled(false);
} }
WebKit::WebString StdStringToWebString(const std::string& str) { WebKit::WebString StdStringToWebString(const std::string& str) {
return WebKit::WebString::fromUTF8(str.data(), str.size()); return WebKit::WebString::fromUTF8(str.data(), str.size());
} }
std::string WebStringToStdString(const WebKit::WebString& str) { std::string WebStringToStdString(const WebKit::WebString& str) {
std::string ret; std::string ret;
if (!str.isNull()) if (!str.isNull())
UTF16ToUTF8(str.data(), str.length(), &ret); UTF16ToUTF8(str.data(), str.length(), &ret);
return ret; return ret;
} }
std::string GetProductVersion() { std::string GetProductVersion() {
return std::string("Chrome/7.0.517.0"); return std::string("Chrome/7.0.517.0");
} }
bool IsSingleProcess() { bool IsSingleProcess() {
return true; return true;
} }
#if defined(OS_LINUX) #if defined(OS_LINUX)
int MatchFontWithFallback(const std::string& face, bool bold, int MatchFontWithFallback(const std::string& face, bool bold,
bool italic, int charset) { bool italic, int charset) {
return -1; return -1;
} }
bool GetFontTable(int fd, uint32_t table, uint8_t* output, bool GetFontTable(int fd, uint32_t table, uint8_t* output,
size_t* output_length) { size_t* output_length) {
return false; return false;
} }
#endif #endif
void EnableSpdy(bool enable) { void EnableSpdy(bool enable) {
// Used in benchmarking, Ignored for CEF. // Used in benchmarking, Ignored for CEF.
} }
} // namespace webkit_glue } // namespace webkit_glue

View File

@ -1,46 +1,46 @@
// Copyright (c) 2008-2009 The Chromium Embedded Framework Authors. All rights // Copyright (c) 2008-2009 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that // reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file. // can be found in the LICENSE file.
#if defined(OS_WIN) #if defined(OS_WIN)
#include <windows.h> #include <windows.h>
#endif #endif
#include <string> #include <string>
#include "base/string_piece.h" #include "base/string_piece.h"
#include "v8/include/v8.h" #include "v8/include/v8.h"
namespace WebKit { namespace WebKit {
class WebFrame; class WebFrame;
class WebString; class WebString;
class WebView; class WebView;
} }
namespace webkit_glue { namespace webkit_glue {
#if defined(OS_WIN) #if defined(OS_WIN)
// Capture a bitmap of the web view. // Capture a bitmap of the web view.
void CaptureWebViewBitmap(HWND mainWnd, WebKit::WebView* webview, void CaptureWebViewBitmap(HWND mainWnd, WebKit::WebView* webview,
HBITMAP& bitmap, SIZE& size); HBITMAP& bitmap, SIZE& size);
// Save a bitmap image to file, providing optional alternative data in |lpBits| // Save a bitmap image to file, providing optional alternative data in |lpBits|
BOOL SaveBitmapToFile(HBITMAP hBmp, HDC hDC, LPCTSTR file, LPBYTE lpBits); BOOL SaveBitmapToFile(HBITMAP hBmp, HDC hDC, LPCTSTR file, LPBYTE lpBits);
#endif #endif
// Text encoding objects must be initialized on the main thread. // Text encoding objects must be initialized on the main thread.
void InitializeTextEncoding(); void InitializeTextEncoding();
// This is called indirectly by the network layer to access resources. // This is called indirectly by the network layer to access resources.
base::StringPiece NetResourceProvider(int key); base::StringPiece NetResourceProvider(int key);
// Retrieve the V8 context associated with the frame. // Retrieve the V8 context associated with the frame.
v8::Handle<v8::Context> GetV8Context(WebKit::WebFrame* frame); v8::Handle<v8::Context> GetV8Context(WebKit::WebFrame* frame);
// Clear all cached data. // Clear all cached data.
void ClearCache(); void ClearCache();
WebKit::WebString StdStringToWebString(const std::string& str); WebKit::WebString StdStringToWebString(const std::string& str);
std::string WebStringToStdString(const WebKit::WebString& str); std::string WebStringToStdString(const WebKit::WebString& str);
} // namespace webkit_glue } // namespace webkit_glue

View File

@ -1,310 +1,310 @@
// Copyright (c) 2008 The Chromium Embedded Framework Authors. // Copyright (c) 2008 The Chromium Embedded Framework Authors.
// Portions copyright (c) 2006-2008 The Chromium Authors. All rights reserved. // Portions copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include <atlcore.h> #include <atlcore.h>
#include <atlbase.h> #include <atlbase.h>
#include <commdlg.h> #include <commdlg.h>
#include "base/compiler_specific.h" #include "base/compiler_specific.h"
#include "third_party/webkit/webcore/config.h" #include "third_party/webkit/webcore/config.h"
MSVC_PUSH_WARNING_LEVEL(0); MSVC_PUSH_WARNING_LEVEL(0);
#include "PlatformContextSkia.h" #include "PlatformContextSkia.h"
MSVC_POP_WARNING(); MSVC_POP_WARNING();
#include "browser_webkit_glue.h" #include "browser_webkit_glue.h"
#undef LOG #undef LOG
#include "base/logging.h" #include "base/logging.h"
#include "base/resource_util.h" #include "base/resource_util.h"
#include "gfx/gdi_util.h" #include "gfx/gdi_util.h"
#include "skia/ext/platform_canvas.h" #include "skia/ext/platform_canvas.h"
#include "third_party/WebKit/WebKit/chromium/public/WebRect.h" #include "third_party/WebKit/WebKit/chromium/public/WebRect.h"
#include "third_party/WebKit/WebKit/chromium/public/WebSize.h" #include "third_party/WebKit/WebKit/chromium/public/WebSize.h"
#include "third_party/WebKit/WebKit/chromium/public/WebView.h" #include "third_party/WebKit/WebKit/chromium/public/WebView.h"
#include "webkit/glue/webkit_glue.h" #include "webkit/glue/webkit_glue.h"
#include "webkit/glue/plugins/plugin_list.h" #include "webkit/glue/plugins/plugin_list.h"
using WebKit::WebRect; using WebKit::WebRect;
using WebKit::WebSize; using WebKit::WebSize;
using WebKit::WebView; using WebKit::WebView;
namespace webkit_glue { namespace webkit_glue {
string16 GetLocalizedString(int message_id) { string16 GetLocalizedString(int message_id) {
// Localized resources are provided via webkit_resources.rc and // Localized resources are provided via webkit_resources.rc and
// webkit_strings_en-US.rc. // webkit_strings_en-US.rc.
const ATLSTRINGRESOURCEIMAGE* image = const ATLSTRINGRESOURCEIMAGE* image =
AtlGetStringResourceImage(_AtlBaseModule.GetModuleInstance(), AtlGetStringResourceImage(_AtlBaseModule.GetModuleInstance(),
message_id); message_id);
if (!image) { if (!image) {
NOTREACHED(); NOTREACHED();
return L"No string for this identifier!"; return L"No string for this identifier!";
} }
return string16(image->achString, image->nLength); return string16(image->achString, image->nLength);
} }
HCURSOR LoadCursor(int cursor_id) { HCURSOR LoadCursor(int cursor_id) {
return NULL; return NULL;
} }
base::StringPiece GetRawDataResource(HMODULE module, int resource_id) { base::StringPiece GetRawDataResource(HMODULE module, int resource_id) {
void* data_ptr; void* data_ptr;
size_t data_size; size_t data_size;
return base::GetDataResourceFromModule(module, resource_id, &data_ptr, return base::GetDataResourceFromModule(module, resource_id, &data_ptr,
&data_size) &data_size)
? base::StringPiece(static_cast<char*>(data_ptr), data_size) ? base::StringPiece(static_cast<char*>(data_ptr), data_size)
: base::StringPiece(); : base::StringPiece();
} }
base::StringPiece NetResourceProvider(int key) { base::StringPiece NetResourceProvider(int key) {
HMODULE hModule = ::GetModuleHandle(L"libcef.dll"); HMODULE hModule = ::GetModuleHandle(L"libcef.dll");
if(!hModule) if(!hModule)
hModule = ::GetModuleHandle(NULL); hModule = ::GetModuleHandle(NULL);
return GetRawDataResource(hModule, key); return GetRawDataResource(hModule, key);
} }
void GetPlugins(bool refresh, std::vector<WebPluginInfo>* plugins) { void GetPlugins(bool refresh, std::vector<WebPluginInfo>* plugins) {
NPAPI::PluginList::Singleton()->GetPlugins(refresh, plugins); NPAPI::PluginList::Singleton()->GetPlugins(refresh, plugins);
} }
bool EnsureFontLoaded(HFONT font) { bool EnsureFontLoaded(HFONT font) {
return true; return true;
} }
bool DownloadUrl(const std::string& url, HWND caller_window) { bool DownloadUrl(const std::string& url, HWND caller_window) {
return false; return false;
} }
void CaptureWebViewBitmap(HWND mainWnd, WebView* webview, HBITMAP& bitmap, void CaptureWebViewBitmap(HWND mainWnd, WebView* webview, HBITMAP& bitmap,
SIZE& size) SIZE& size)
{ {
WebKit::WebSize webSize = webview->size(); WebKit::WebSize webSize = webview->size();
size.cx = webSize.width; size.cx = webSize.width;
size.cy = webSize.height; size.cy = webSize.height;
skia::PlatformCanvas canvas(size.cx, size.cy, true); skia::PlatformCanvas canvas(size.cx, size.cy, true);
canvas.drawARGB(255, 255, 255, 255, SkXfermode::kSrc_Mode); canvas.drawARGB(255, 255, 255, 255, SkXfermode::kSrc_Mode);
WebCore::PlatformContextSkia context(&canvas); WebCore::PlatformContextSkia context(&canvas);
WebKit::WebRect rect(0, 0, size.cx, size.cy); WebKit::WebRect rect(0, 0, size.cx, size.cy);
webview->layout(); webview->layout();
webview->paint(&canvas, rect); webview->paint(&canvas, rect);
HDC hRefDC = GetDC(mainWnd); HDC hRefDC = GetDC(mainWnd);
HDC hDC = CreateCompatibleDC(hRefDC); HDC hDC = CreateCompatibleDC(hRefDC);
bitmap = CreateCompatibleBitmap(hRefDC, size.cx, size.cy); bitmap = CreateCompatibleBitmap(hRefDC, size.cx, size.cy);
DCHECK(bitmap != NULL); DCHECK(bitmap != NULL);
HBITMAP hOldBmp = (HBITMAP)SelectObject(hDC, bitmap); HBITMAP hOldBmp = (HBITMAP)SelectObject(hDC, bitmap);
// Create a BMP v4 header that we can serialize. // Create a BMP v4 header that we can serialize.
BITMAPV4HEADER bitmap_header; BITMAPV4HEADER bitmap_header;
gfx::CreateBitmapV4Header(size.cx, size.cy, &bitmap_header); gfx::CreateBitmapV4Header(size.cx, size.cy, &bitmap_header);
const SkBitmap& src_bmp = canvas.getDevice()->accessBitmap(true); const SkBitmap& src_bmp = canvas.getDevice()->accessBitmap(true);
SkAutoLockPixels src_lock(src_bmp); SkAutoLockPixels src_lock(src_bmp);
int retval = StretchDIBits(hDC, int retval = StretchDIBits(hDC,
0, 0,
0, 0,
size.cx, size.cy, size.cx, size.cy,
0, 0, 0, 0,
size.cx, size.cy, size.cx, size.cy,
src_bmp.getPixels(), src_bmp.getPixels(),
reinterpret_cast<BITMAPINFO*>(&bitmap_header), reinterpret_cast<BITMAPINFO*>(&bitmap_header),
DIB_RGB_COLORS, DIB_RGB_COLORS,
SRCCOPY); SRCCOPY);
DCHECK(retval != GDI_ERROR); DCHECK(retval != GDI_ERROR);
SelectObject(hDC, hOldBmp); SelectObject(hDC, hOldBmp);
DeleteDC(hDC); DeleteDC(hDC);
ReleaseDC(mainWnd, hRefDC); ReleaseDC(mainWnd, hRefDC);
} }
static PBITMAPINFO BmpCreateInfo(HBITMAP hBmp) static PBITMAPINFO BmpCreateInfo(HBITMAP hBmp)
{ {
BITMAP bmp; BITMAP bmp;
PBITMAPINFO pbmi; PBITMAPINFO pbmi;
WORD cClrBits; WORD cClrBits;
// Retrieve the bitmap color format, width, and height. // Retrieve the bitmap color format, width, and height.
if (!GetObject(hBmp, sizeof(BITMAP), (LPSTR)&bmp)) { if (!GetObject(hBmp, sizeof(BITMAP), (LPSTR)&bmp)) {
NOTREACHED(); NOTREACHED();
return NULL; return NULL;
} }
// Convert the color format to a count of bits. // Convert the color format to a count of bits.
cClrBits = (WORD)(bmp.bmPlanes * bmp.bmBitsPixel); cClrBits = (WORD)(bmp.bmPlanes * bmp.bmBitsPixel);
if (cClrBits == 1) { if (cClrBits == 1) {
cClrBits = 1; cClrBits = 1;
} else if (cClrBits <= 4) { } else if (cClrBits <= 4) {
cClrBits = 4; cClrBits = 4;
} else if (cClrBits <= 8) { } else if (cClrBits <= 8) {
cClrBits = 8; cClrBits = 8;
} else if (cClrBits <= 16) { } else if (cClrBits <= 16) {
cClrBits = 16; cClrBits = 16;
} else if (cClrBits <= 24) { } else if (cClrBits <= 24) {
cClrBits = 24; cClrBits = 24;
} else { } else {
cClrBits = 32; cClrBits = 32;
} }
// Allocate memory for the BITMAPINFO structure. (This structure // Allocate memory for the BITMAPINFO structure. (This structure
// contains a BITMAPINFOHEADER structure and an array of RGBQUAD // contains a BITMAPINFOHEADER structure and an array of RGBQUAD
// data structures.) // data structures.)
if (cClrBits != 24) { if (cClrBits != 24) {
pbmi = (PBITMAPINFO) LocalAlloc(LPTR, pbmi = (PBITMAPINFO) LocalAlloc(LPTR,
sizeof(BITMAPINFOHEADER) + sizeof(RGBQUAD) * (1<< cClrBits)); sizeof(BITMAPINFOHEADER) + sizeof(RGBQUAD) * (1<< cClrBits));
} else { // There is no RGBQUAD array for the 24-bit-per-pixel format. } else { // There is no RGBQUAD array for the 24-bit-per-pixel format.
pbmi = (PBITMAPINFO) LocalAlloc(LPTR, sizeof(BITMAPINFOHEADER)); pbmi = (PBITMAPINFO) LocalAlloc(LPTR, sizeof(BITMAPINFOHEADER));
} }
// Initialize the fields in the BITMAPINFO structure. // Initialize the fields in the BITMAPINFO structure.
pbmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); pbmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
pbmi->bmiHeader.biWidth = bmp.bmWidth; pbmi->bmiHeader.biWidth = bmp.bmWidth;
pbmi->bmiHeader.biHeight = bmp.bmHeight; pbmi->bmiHeader.biHeight = bmp.bmHeight;
pbmi->bmiHeader.biPlanes = bmp.bmPlanes; pbmi->bmiHeader.biPlanes = bmp.bmPlanes;
pbmi->bmiHeader.biBitCount = bmp.bmBitsPixel; pbmi->bmiHeader.biBitCount = bmp.bmBitsPixel;
if (cClrBits < 24) { if (cClrBits < 24) {
pbmi->bmiHeader.biClrUsed = (1<<cClrBits); pbmi->bmiHeader.biClrUsed = (1<<cClrBits);
} }
// If the bitmap is not compressed, set the BI_RGB flag. // If the bitmap is not compressed, set the BI_RGB flag.
pbmi->bmiHeader.biCompression = BI_RGB; pbmi->bmiHeader.biCompression = BI_RGB;
// Compute the number of bytes in the array of color // Compute the number of bytes in the array of color
// indices and store the result in biSizeImage. // indices and store the result in biSizeImage.
// For Windows NT, the width must be DWORD aligned unless // For Windows NT, the width must be DWORD aligned unless
// the bitmap is RLE compressed. This example shows this. // the bitmap is RLE compressed. This example shows this.
// For Windows 95/98/Me, the width must be WORD aligned unless the // For Windows 95/98/Me, the width must be WORD aligned unless the
// bitmap is RLE compressed. // bitmap is RLE compressed.
pbmi->bmiHeader.biSizeImage = pbmi->bmiHeader.biSizeImage =
((pbmi->bmiHeader.biWidth * cClrBits +31) & ~31) /8 ((pbmi->bmiHeader.biWidth * cClrBits +31) & ~31) /8
* pbmi->bmiHeader.biHeight; * pbmi->bmiHeader.biHeight;
// Set biClrImportant to 0, indicating that all of the // Set biClrImportant to 0, indicating that all of the
// device colors are important. // device colors are important.
pbmi->bmiHeader.biClrImportant = 0; pbmi->bmiHeader.biClrImportant = 0;
return pbmi; return pbmi;
} }
static BOOL BmpSaveFile(LPCTSTR pszFile, PBITMAPINFO pbi, HBITMAP hBMP, static BOOL BmpSaveFile(LPCTSTR pszFile, PBITMAPINFO pbi, HBITMAP hBMP,
HDC hDC, LPBYTE lpBits = NULL) HDC hDC, LPBYTE lpBits = NULL)
{ {
HANDLE hf = INVALID_HANDLE_VALUE; // file handle HANDLE hf = INVALID_HANDLE_VALUE; // file handle
BITMAPFILEHEADER hdr; // bitmap file-header BITMAPFILEHEADER hdr; // bitmap file-header
PBITMAPINFOHEADER pbih; // bitmap info-header PBITMAPINFOHEADER pbih; // bitmap info-header
DWORD dwTotal; // total count of bytes DWORD dwTotal; // total count of bytes
DWORD cb; // incremental count of bytes DWORD cb; // incremental count of bytes
BYTE *hp; // byte pointer BYTE *hp; // byte pointer
DWORD dwTmp; DWORD dwTmp;
BOOL ret = FALSE; BOOL ret = FALSE;
BOOL bitsAlloc = FALSE; BOOL bitsAlloc = FALSE;
pbih = (PBITMAPINFOHEADER) pbi; pbih = (PBITMAPINFOHEADER) pbi;
if(!lpBits) { if(!lpBits) {
// The bits have not been provided, so retrieve from the bitmap file // The bits have not been provided, so retrieve from the bitmap file
lpBits = (LPBYTE) GlobalAlloc(GMEM_FIXED, pbih->biSizeImage); lpBits = (LPBYTE) GlobalAlloc(GMEM_FIXED, pbih->biSizeImage);
if (!lpBits) { if (!lpBits) {
// Memory could not be allocated // Memory could not be allocated
NOTREACHED(); NOTREACHED();
return FALSE; return FALSE;
} }
bitsAlloc = TRUE; bitsAlloc = TRUE;
// Retrieve the color table (RGBQUAD array) and the bits // Retrieve the color table (RGBQUAD array) and the bits
// (array of palette indices) from the DIB. // (array of palette indices) from the DIB.
if (!GetDIBits(hDC, hBMP, 0, (WORD) pbih->biHeight, lpBits, pbi, if (!GetDIBits(hDC, hBMP, 0, (WORD) pbih->biHeight, lpBits, pbi,
DIB_RGB_COLORS)) { DIB_RGB_COLORS)) {
NOTREACHED(); NOTREACHED();
goto end; goto end;
} }
} }
// Create the bitmap file. // Create the bitmap file.
hf = CreateFile(pszFile, hf = CreateFile(pszFile,
GENERIC_READ | GENERIC_WRITE, GENERIC_READ | GENERIC_WRITE,
(DWORD) 0, (DWORD) 0,
NULL, NULL,
CREATE_ALWAYS, CREATE_ALWAYS,
FILE_ATTRIBUTE_NORMAL, FILE_ATTRIBUTE_NORMAL,
(HANDLE) NULL); (HANDLE) NULL);
if (hf == INVALID_HANDLE_VALUE) { if (hf == INVALID_HANDLE_VALUE) {
// Could not create the bitmap file // Could not create the bitmap file
NOTREACHED(); NOTREACHED();
goto end; goto end;
} }
hdr.bfType = 0x4d42; // 0x42 = "B", 0x4d = "M" hdr.bfType = 0x4d42; // 0x42 = "B", 0x4d = "M"
// Compute the size of the entire file. // Compute the size of the entire file.
hdr.bfSize = (DWORD) (sizeof(BITMAPFILEHEADER) + hdr.bfSize = (DWORD) (sizeof(BITMAPFILEHEADER) +
pbih->biSize + pbih->biClrUsed pbih->biSize + pbih->biClrUsed
* sizeof(RGBQUAD) + pbih->biSizeImage); * sizeof(RGBQUAD) + pbih->biSizeImage);
hdr.bfReserved1 = 0; hdr.bfReserved1 = 0;
hdr.bfReserved2 = 0; hdr.bfReserved2 = 0;
// Compute the offset to the array of color indices. // Compute the offset to the array of color indices.
hdr.bfOffBits = (DWORD) sizeof(BITMAPFILEHEADER) + hdr.bfOffBits = (DWORD) sizeof(BITMAPFILEHEADER) +
pbih->biSize + pbih->biClrUsed pbih->biSize + pbih->biClrUsed
* sizeof (RGBQUAD); * sizeof (RGBQUAD);
// Copy the BITMAPFILEHEADER into the bitmap file. // Copy the BITMAPFILEHEADER into the bitmap file.
if (!WriteFile(hf, (LPVOID) &hdr, sizeof(BITMAPFILEHEADER), if (!WriteFile(hf, (LPVOID) &hdr, sizeof(BITMAPFILEHEADER),
(LPDWORD) &dwTmp, NULL)) { (LPDWORD) &dwTmp, NULL)) {
// Could not write bitmap file header to file // Could not write bitmap file header to file
NOTREACHED(); NOTREACHED();
goto end; goto end;
} }
// Copy the BITMAPINFOHEADER and RGBQUAD array into the file. // Copy the BITMAPINFOHEADER and RGBQUAD array into the file.
if (!WriteFile(hf, (LPVOID) pbih, sizeof(BITMAPINFOHEADER) if (!WriteFile(hf, (LPVOID) pbih, sizeof(BITMAPINFOHEADER)
+ pbih->biClrUsed * sizeof (RGBQUAD), + pbih->biClrUsed * sizeof (RGBQUAD),
(LPDWORD) &dwTmp, NULL)) { (LPDWORD) &dwTmp, NULL)) {
// Could not write bitmap info header to file // Could not write bitmap info header to file
NOTREACHED(); NOTREACHED();
goto end; goto end;
} }
// Copy the array of color indices into the .BMP file. // Copy the array of color indices into the .BMP file.
dwTotal = cb = pbih->biSizeImage; dwTotal = cb = pbih->biSizeImage;
hp = lpBits; hp = lpBits;
if (!WriteFile(hf, (LPSTR) hp, (int) cb, (LPDWORD) &dwTmp,NULL)) { if (!WriteFile(hf, (LPSTR) hp, (int) cb, (LPDWORD) &dwTmp,NULL)) {
// Could not write bitmap data to file // Could not write bitmap data to file
NOTREACHED(); NOTREACHED();
goto end; goto end;
} }
ret = TRUE; ret = TRUE;
end: end:
// Close the bitmap file. // Close the bitmap file.
if(hf != INVALID_HANDLE_VALUE) { if(hf != INVALID_HANDLE_VALUE) {
CloseHandle(hf); CloseHandle(hf);
if(!ret) if(!ret)
DeleteFile(pszFile); DeleteFile(pszFile);
} }
if(bitsAlloc) if(bitsAlloc)
{ {
// Free memory. // Free memory.
GlobalFree((HGLOBAL)lpBits); GlobalFree((HGLOBAL)lpBits);
} }
return ret; return ret;
} }
BOOL SaveBitmapToFile(HBITMAP hBmp, HDC hDC, LPCTSTR file, LPBYTE lpBits) BOOL SaveBitmapToFile(HBITMAP hBmp, HDC hDC, LPCTSTR file, LPBYTE lpBits)
{ {
PBITMAPINFO pbmi = BmpCreateInfo(hBmp); PBITMAPINFO pbmi = BmpCreateInfo(hBmp);
BOOL ret = FALSE; BOOL ret = FALSE;
if(pbmi) { if(pbmi) {
ret = BmpSaveFile(file, pbmi, hBmp, hDC, lpBits); ret = BmpSaveFile(file, pbmi, hBmp, hDC, lpBits);
LocalFree(pbmi); LocalFree(pbmi);
} }
return ret; return ret;
} }
} // namespace webkit_glue } // namespace webkit_glue

View File

@ -1,227 +1,227 @@
// Copyright (c) 2009 The Chromium Embedded Framework Authors. // Copyright (c) 2009 The Chromium Embedded Framework Authors.
// Portions copyright (c) 2009 The Chromium Authors. All rights reserved. // Portions copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef _BROWSER_WEBKIT_INIT_H #ifndef _BROWSER_WEBKIT_INIT_H
#define _BROWSER_WEBKIT_INIT_H #define _BROWSER_WEBKIT_INIT_H
#include "base/file_util.h" #include "base/file_util.h"
#include "base/path_service.h" #include "base/path_service.h"
#include "base/scoped_temp_dir.h" #include "base/scoped_temp_dir.h"
#include "base/stats_counters.h" #include "base/stats_counters.h"
#include "base/utf_string_conversions.h" #include "base/utf_string_conversions.h"
#include "media/base/media.h" #include "media/base/media.h"
#include "webkit/appcache/web_application_cache_host_impl.h" #include "webkit/appcache/web_application_cache_host_impl.h"
#include "webkit/database/vfs_backend.h" #include "webkit/database/vfs_backend.h"
#include "webkit/extensions/v8/gears_extension.h" #include "webkit/extensions/v8/gears_extension.h"
#include "third_party/WebKit/WebKit/chromium/public/WebData.h" #include "third_party/WebKit/WebKit/chromium/public/WebData.h"
#include "third_party/WebKit/WebKit/chromium/public/WebDatabase.h" #include "third_party/WebKit/WebKit/chromium/public/WebDatabase.h"
#include "third_party/WebKit/WebKit/chromium/public/WebKit.h" #include "third_party/WebKit/WebKit/chromium/public/WebKit.h"
#include "third_party/WebKit/WebKit/chromium/public/WebRuntimeFeatures.h" #include "third_party/WebKit/WebKit/chromium/public/WebRuntimeFeatures.h"
#include "third_party/WebKit/WebKit/chromium/public/WebScriptController.h" #include "third_party/WebKit/WebKit/chromium/public/WebScriptController.h"
#include "third_party/WebKit/WebKit/chromium/public/WebSecurityPolicy.h" #include "third_party/WebKit/WebKit/chromium/public/WebSecurityPolicy.h"
#include "third_party/WebKit/WebKit/chromium/public/WebStorageArea.h" #include "third_party/WebKit/WebKit/chromium/public/WebStorageArea.h"
#include "third_party/WebKit/WebKit/chromium/public/WebStorageEventDispatcher.h" #include "third_party/WebKit/WebKit/chromium/public/WebStorageEventDispatcher.h"
#include "third_party/WebKit/WebKit/chromium/public/WebIDBFactory.h" #include "third_party/WebKit/WebKit/chromium/public/WebIDBFactory.h"
#include "third_party/WebKit/WebKit/chromium/public/WebIDBKey.h" #include "third_party/WebKit/WebKit/chromium/public/WebIDBKey.h"
#include "third_party/WebKit/WebKit/chromium/public/WebIDBKeyPath.h" #include "third_party/WebKit/WebKit/chromium/public/WebIDBKeyPath.h"
#include "third_party/WebKit/WebKit/chromium/public/WebSerializedScriptValue.h" #include "third_party/WebKit/WebKit/chromium/public/WebSerializedScriptValue.h"
#include "third_party/WebKit/WebKit/chromium/public/WebStorageNamespace.h" #include "third_party/WebKit/WebKit/chromium/public/WebStorageNamespace.h"
#include "third_party/WebKit/WebKit/chromium/public/WebString.h" #include "third_party/WebKit/WebKit/chromium/public/WebString.h"
#include "webkit/glue/simple_webmimeregistry_impl.h" #include "webkit/glue/simple_webmimeregistry_impl.h"
#include "webkit/glue/webclipboard_impl.h" #include "webkit/glue/webclipboard_impl.h"
#include "webkit/glue/webfileutilities_impl.h" #include "webkit/glue/webfileutilities_impl.h"
#include "webkit/glue/webkit_glue.h" #include "webkit/glue/webkit_glue.h"
#include "webkit/glue/webkitclient_impl.h" #include "webkit/glue/webkitclient_impl.h"
#include "browser_appcache_system.h" #include "browser_appcache_system.h"
#include "browser_database_system.h" #include "browser_database_system.h"
#include "browser_file_system.h" #include "browser_file_system.h"
#include "browser_resource_loader_bridge.h" #include "browser_resource_loader_bridge.h"
#include "browser_webblobregistry_impl.h" #include "browser_webblobregistry_impl.h"
#include "browser_webcookiejar_impl.h" #include "browser_webcookiejar_impl.h"
class BrowserWebKitInit : public webkit_glue::WebKitClientImpl { class BrowserWebKitInit : public webkit_glue::WebKitClientImpl {
public: public:
explicit BrowserWebKitInit() { explicit BrowserWebKitInit() {
v8::V8::SetCounterFunction(StatsTable::FindLocation); v8::V8::SetCounterFunction(StatsTable::FindLocation);
WebKit::initialize(this); WebKit::initialize(this);
WebKit::setLayoutTestMode(false); WebKit::setLayoutTestMode(false);
WebKit::WebScriptController::registerExtension( WebKit::WebScriptController::registerExtension(
extensions_v8::GearsExtension::Get()); extensions_v8::GearsExtension::Get());
WebKit::WebRuntimeFeatures::enableSockets(true); WebKit::WebRuntimeFeatures::enableSockets(true);
WebKit::WebRuntimeFeatures::enableApplicationCache(true); WebKit::WebRuntimeFeatures::enableApplicationCache(true);
WebKit::WebRuntimeFeatures::enableDatabase(true); WebKit::WebRuntimeFeatures::enableDatabase(true);
WebKit::WebRuntimeFeatures::enableWebGL(true); WebKit::WebRuntimeFeatures::enableWebGL(true);
WebKit::WebRuntimeFeatures::enablePushState(true); WebKit::WebRuntimeFeatures::enablePushState(true);
WebKit::WebRuntimeFeatures::enableNotifications(true); WebKit::WebRuntimeFeatures::enableNotifications(true);
WebKit::WebRuntimeFeatures::enableTouch(true); WebKit::WebRuntimeFeatures::enableTouch(true);
WebKit::WebRuntimeFeatures::enableIndexedDatabase(true); WebKit::WebRuntimeFeatures::enableIndexedDatabase(true);
WebKit::WebRuntimeFeatures::enableGeolocation(false); WebKit::WebRuntimeFeatures::enableGeolocation(false);
WebKit::WebRuntimeFeatures::enableSpeechInput(true); WebKit::WebRuntimeFeatures::enableSpeechInput(true);
WebKit::WebRuntimeFeatures::enableFileSystem(true); WebKit::WebRuntimeFeatures::enableFileSystem(true);
// TODO(hwennborg): Enable this once the implementation supports it. // TODO(hwennborg): Enable this once the implementation supports it.
WebKit::WebRuntimeFeatures::enableDeviceMotion(false); WebKit::WebRuntimeFeatures::enableDeviceMotion(false);
WebKit::WebRuntimeFeatures::enableDeviceOrientation(false); WebKit::WebRuntimeFeatures::enableDeviceOrientation(false);
// Load libraries for media and enable the media player. // Load libraries for media and enable the media player.
FilePath module_path; FilePath module_path;
WebKit::WebRuntimeFeatures::enableMediaPlayer( WebKit::WebRuntimeFeatures::enableMediaPlayer(
PathService::Get(base::DIR_MODULE, &module_path) && PathService::Get(base::DIR_MODULE, &module_path) &&
media::InitializeMediaLibrary(module_path)); media::InitializeMediaLibrary(module_path));
// Construct and initialize an appcache system for this scope. // Construct and initialize an appcache system for this scope.
// A new empty temp directory is created to house any cached // A new empty temp directory is created to house any cached
// content during the run. Upon exit that directory is deleted. // content during the run. Upon exit that directory is deleted.
// If we can't create a tempdir, we'll use in-memory storage. // If we can't create a tempdir, we'll use in-memory storage.
if (!appcache_dir_.CreateUniqueTempDir()) { if (!appcache_dir_.CreateUniqueTempDir()) {
LOG(WARNING) << "Failed to create a temp dir for the appcache, " LOG(WARNING) << "Failed to create a temp dir for the appcache, "
"using in-memory storage."; "using in-memory storage.";
DCHECK(appcache_dir_.path().empty()); DCHECK(appcache_dir_.path().empty());
} }
BrowserAppCacheSystem::InitializeOnUIThread(appcache_dir_.path()); BrowserAppCacheSystem::InitializeOnUIThread(appcache_dir_.path());
WebKit::WebDatabase::setObserver(&database_system_); WebKit::WebDatabase::setObserver(&database_system_);
blob_registry_ = new BrowserWebBlobRegistryImpl(); blob_registry_ = new BrowserWebBlobRegistryImpl();
file_utilities_.set_sandbox_enabled(false); file_utilities_.set_sandbox_enabled(false);
} }
~BrowserWebKitInit() { ~BrowserWebKitInit() {
WebKit::shutdown(); WebKit::shutdown();
} }
virtual WebKit::WebMimeRegistry* mimeRegistry() { virtual WebKit::WebMimeRegistry* mimeRegistry() {
return &mime_registry_; return &mime_registry_;
} }
WebKit::WebClipboard* clipboard() { WebKit::WebClipboard* clipboard() {
return &clipboard_; return &clipboard_;
} }
virtual WebKit::WebFileUtilities* fileUtilities() { virtual WebKit::WebFileUtilities* fileUtilities() {
return &file_utilities_; return &file_utilities_;
} }
virtual WebKit::WebSandboxSupport* sandboxSupport() { virtual WebKit::WebSandboxSupport* sandboxSupport() {
return NULL; return NULL;
} }
virtual WebKit::WebBlobRegistry* blobRegistry() { virtual WebKit::WebBlobRegistry* blobRegistry() {
return blob_registry_.get(); return blob_registry_.get();
} }
virtual WebKit::WebCookieJar* cookieJar() { virtual WebKit::WebCookieJar* cookieJar() {
return &cookie_jar_; return &cookie_jar_;
} }
virtual WebKit::WebFileSystem* fileSystem() { virtual WebKit::WebFileSystem* fileSystem() {
return &file_system_; return &file_system_;
} }
virtual bool sandboxEnabled() { virtual bool sandboxEnabled() {
return true; return true;
} }
virtual WebKit::WebKitClient::FileHandle databaseOpenFile( virtual WebKit::WebKitClient::FileHandle databaseOpenFile(
const WebKit::WebString& vfs_file_name, int desired_flags) { const WebKit::WebString& vfs_file_name, int desired_flags) {
return BrowserDatabaseSystem::GetInstance()->OpenFile( return BrowserDatabaseSystem::GetInstance()->OpenFile(
vfs_file_name, desired_flags); vfs_file_name, desired_flags);
} }
virtual int databaseDeleteFile(const WebKit::WebString& vfs_file_name, virtual int databaseDeleteFile(const WebKit::WebString& vfs_file_name,
bool sync_dir) { bool sync_dir) {
return BrowserDatabaseSystem::GetInstance()->DeleteFile( return BrowserDatabaseSystem::GetInstance()->DeleteFile(
vfs_file_name, sync_dir); vfs_file_name, sync_dir);
} }
virtual long databaseGetFileAttributes( virtual long databaseGetFileAttributes(
const WebKit::WebString& vfs_file_name) { const WebKit::WebString& vfs_file_name) {
return BrowserDatabaseSystem::GetInstance()->GetFileAttributes( return BrowserDatabaseSystem::GetInstance()->GetFileAttributes(
vfs_file_name); vfs_file_name);
} }
virtual long long databaseGetFileSize( virtual long long databaseGetFileSize(
const WebKit::WebString& vfs_file_name) { const WebKit::WebString& vfs_file_name) {
return BrowserDatabaseSystem::GetInstance()->GetFileSize(vfs_file_name); return BrowserDatabaseSystem::GetInstance()->GetFileSize(vfs_file_name);
} }
virtual unsigned long long visitedLinkHash(const char* canonicalURL, virtual unsigned long long visitedLinkHash(const char* canonicalURL,
size_t length) { size_t length) {
return 0; return 0;
} }
virtual bool isLinkVisited(unsigned long long linkHash) { virtual bool isLinkVisited(unsigned long long linkHash) {
return false; return false;
} }
virtual WebKit::WebMessagePortChannel* createMessagePortChannel() { virtual WebKit::WebMessagePortChannel* createMessagePortChannel() {
return NULL; return NULL;
} }
virtual void prefetchHostName(const WebKit::WebString&) { virtual void prefetchHostName(const WebKit::WebString&) {
} }
virtual WebKit::WebData loadResource(const char* name) { virtual WebKit::WebData loadResource(const char* name) {
if (!strcmp(name, "deleteButton")) { if (!strcmp(name, "deleteButton")) {
// Create a red 30x30 square. // Create a red 30x30 square.
const char red_square[] = const char red_square[] =
"\x89\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52" "\x89\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52"
"\x00\x00\x00\x1e\x00\x00\x00\x1e\x04\x03\x00\x00\x00\xc9\x1e\xb3" "\x00\x00\x00\x1e\x00\x00\x00\x1e\x04\x03\x00\x00\x00\xc9\x1e\xb3"
"\x91\x00\x00\x00\x30\x50\x4c\x54\x45\x00\x00\x00\x80\x00\x00\x00" "\x91\x00\x00\x00\x30\x50\x4c\x54\x45\x00\x00\x00\x80\x00\x00\x00"
"\x80\x00\x80\x80\x00\x00\x00\x80\x80\x00\x80\x00\x80\x80\x80\x80" "\x80\x00\x80\x80\x00\x00\x00\x80\x80\x00\x80\x00\x80\x80\x80\x80"
"\x80\xc0\xc0\xc0\xff\x00\x00\x00\xff\x00\xff\xff\x00\x00\x00\xff" "\x80\xc0\xc0\xc0\xff\x00\x00\x00\xff\x00\xff\xff\x00\x00\x00\xff"
"\xff\x00\xff\x00\xff\xff\xff\xff\xff\x7b\x1f\xb1\xc4\x00\x00\x00" "\xff\x00\xff\x00\xff\xff\xff\xff\xff\x7b\x1f\xb1\xc4\x00\x00\x00"
"\x09\x70\x48\x59\x73\x00\x00\x0b\x13\x00\x00\x0b\x13\x01\x00\x9a" "\x09\x70\x48\x59\x73\x00\x00\x0b\x13\x00\x00\x0b\x13\x01\x00\x9a"
"\x9c\x18\x00\x00\x00\x17\x49\x44\x41\x54\x78\x01\x63\x98\x89\x0a" "\x9c\x18\x00\x00\x00\x17\x49\x44\x41\x54\x78\x01\x63\x98\x89\x0a"
"\x18\x50\xb9\x33\x47\xf9\xa8\x01\x32\xd4\xc2\x03\x00\x33\x84\x0d" "\x18\x50\xb9\x33\x47\xf9\xa8\x01\x32\xd4\xc2\x03\x00\x33\x84\x0d"
"\x02\x3a\x91\xeb\xa5\x00\x00\x00\x00\x49\x45\x4e\x44\xae\x42\x60" "\x02\x3a\x91\xeb\xa5\x00\x00\x00\x00\x49\x45\x4e\x44\xae\x42\x60"
"\x82"; "\x82";
return WebKit::WebData(red_square, arraysize(red_square)); return WebKit::WebData(red_square, arraysize(red_square));
} }
return webkit_glue::WebKitClientImpl::loadResource(name); return webkit_glue::WebKitClientImpl::loadResource(name);
} }
virtual WebKit::WebString defaultLocale() { virtual WebKit::WebString defaultLocale() {
return ASCIIToUTF16("en-US"); return ASCIIToUTF16("en-US");
} }
virtual WebKit::WebStorageNamespace* createLocalStorageNamespace( virtual WebKit::WebStorageNamespace* createLocalStorageNamespace(
const WebKit::WebString& path, unsigned quota) { const WebKit::WebString& path, unsigned quota) {
return WebKit::WebStorageNamespace::createLocalStorageNamespace(path, return WebKit::WebStorageNamespace::createLocalStorageNamespace(path,
WebKit::WebStorageNamespace::m_localStorageQuota); WebKit::WebStorageNamespace::m_localStorageQuota);
} }
virtual WebKit::WebIDBFactory* idbFactory() { virtual WebKit::WebIDBFactory* idbFactory() {
return WebKit::WebIDBFactory::create(); return WebKit::WebIDBFactory::create();
} }
virtual void createIDBKeysFromSerializedValuesAndKeyPath( virtual void createIDBKeysFromSerializedValuesAndKeyPath(
const WebKit::WebVector<WebKit::WebSerializedScriptValue>& values, const WebKit::WebVector<WebKit::WebSerializedScriptValue>& values,
const WebKit::WebString& keyPath, const WebKit::WebString& keyPath,
WebKit::WebVector<WebKit::WebIDBKey>& keys_out) { WebKit::WebVector<WebKit::WebIDBKey>& keys_out) {
WebKit::WebVector<WebKit::WebIDBKey> keys(values.size()); WebKit::WebVector<WebKit::WebIDBKey> keys(values.size());
for (size_t i = 0; i < values.size(); ++i) { for (size_t i = 0; i < values.size(); ++i) {
keys[i] = WebKit::WebIDBKey::createFromValueAndKeyPath( keys[i] = WebKit::WebIDBKey::createFromValueAndKeyPath(
values[i], WebKit::WebIDBKeyPath::create(keyPath)); values[i], WebKit::WebIDBKeyPath::create(keyPath));
} }
keys_out.swap(keys); keys_out.swap(keys);
} }
private: private:
webkit_glue::SimpleWebMimeRegistryImpl mime_registry_; webkit_glue::SimpleWebMimeRegistryImpl mime_registry_;
webkit_glue::WebClipboardImpl clipboard_; webkit_glue::WebClipboardImpl clipboard_;
webkit_glue::WebFileUtilitiesImpl file_utilities_; webkit_glue::WebFileUtilitiesImpl file_utilities_;
ScopedTempDir appcache_dir_; ScopedTempDir appcache_dir_;
BrowserAppCacheSystem appcache_system_; BrowserAppCacheSystem appcache_system_;
BrowserDatabaseSystem database_system_; BrowserDatabaseSystem database_system_;
BrowserWebCookieJarImpl cookie_jar_; BrowserWebCookieJarImpl cookie_jar_;
scoped_refptr<BrowserWebBlobRegistryImpl> blob_registry_; scoped_refptr<BrowserWebBlobRegistryImpl> blob_registry_;
BrowserFileSystem file_system_; BrowserFileSystem file_system_;
}; };
#endif // _BROWSER_WEBKIT_INIT_H #endif // _BROWSER_WEBKIT_INIT_H

File diff suppressed because it is too large Load Diff

View File

@ -1,334 +1,334 @@
// Copyright (c) 2008-2009 The Chromium Embedded Framework Authors. // Copyright (c) 2008-2009 The Chromium Embedded Framework Authors.
// Portions copyright (c) 2006-2008 The Chromium Authors. All rights reserved. // Portions copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// BrowserWebViewDelegate class: // BrowserWebViewDelegate class:
// This class implements the WebViewDelegate methods for the test shell. One // This class implements the WebViewDelegate methods for the test shell. One
// instance is owned by each CefBrowser. // instance is owned by each CefBrowser.
#ifndef _BROWSER_WEBVIEW_DELEGATE_H #ifndef _BROWSER_WEBVIEW_DELEGATE_H
#define _BROWSER_WEBVIEW_DELEGATE_H #define _BROWSER_WEBVIEW_DELEGATE_H
#include "build/build_config.h" #include "build/build_config.h"
#include <map> #include <map>
#if defined(OS_LINUX) #if defined(OS_LINUX)
#include <gdk/gdkcursor.h> #include <gdk/gdkcursor.h>
#endif #endif
#include "base/basictypes.h" #include "base/basictypes.h"
#include "base/scoped_ptr.h" #include "base/scoped_ptr.h"
#include "base/weak_ptr.h" #include "base/weak_ptr.h"
#include "third_party/WebKit/WebKit/chromium/public/WebContextMenuData.h" #include "third_party/WebKit/WebKit/chromium/public/WebContextMenuData.h"
#include "third_party/WebKit/WebKit/chromium/public/WebFileChooserParams.h" #include "third_party/WebKit/WebKit/chromium/public/WebFileChooserParams.h"
#include "third_party/WebKit/WebKit/chromium/public/WebFileSystem.h" #include "third_party/WebKit/WebKit/chromium/public/WebFileSystem.h"
#include "third_party/WebKit/WebKit/chromium/public/WebFrameClient.h" #include "third_party/WebKit/WebKit/chromium/public/WebFrameClient.h"
#include "third_party/WebKit/WebKit/chromium/public/WebRect.h" #include "third_party/WebKit/WebKit/chromium/public/WebRect.h"
#include "third_party/WebKit/WebKit/chromium/public/WebViewClient.h" #include "third_party/WebKit/WebKit/chromium/public/WebViewClient.h"
#include "webkit/glue/webcursor.h" #include "webkit/glue/webcursor.h"
#include "webkit/glue/plugins/webplugin_page_delegate.h" #include "webkit/glue/plugins/webplugin_page_delegate.h"
#if defined(OS_WIN) #if defined(OS_WIN)
#include "browser_drag_delegate.h" #include "browser_drag_delegate.h"
#include "browser_drop_delegate.h" #include "browser_drop_delegate.h"
#endif #endif
#include "browser_navigation_controller.h" #include "browser_navigation_controller.h"
class CefBrowserImpl; class CefBrowserImpl;
struct WebPreferences; struct WebPreferences;
class GURL; class GURL;
class WebWidgetHost; class WebWidgetHost;
class FilePath; class FilePath;
class BrowserWebViewDelegate : public WebKit::WebViewClient, class BrowserWebViewDelegate : public WebKit::WebViewClient,
public WebKit::WebFrameClient, public WebKit::WebFrameClient,
public webkit_glue::WebPluginPageDelegate, public webkit_glue::WebPluginPageDelegate,
public base::SupportsWeakPtr<BrowserWebViewDelegate> { public base::SupportsWeakPtr<BrowserWebViewDelegate> {
public: public:
// WebKit::WebViewClient // WebKit::WebViewClient
virtual WebKit::WebView* createView(WebKit::WebFrame* creator, virtual WebKit::WebView* createView(WebKit::WebFrame* creator,
const WebKit::WebWindowFeatures& features, const WebKit::WebWindowFeatures& features,
const WebKit::WebString& name); const WebKit::WebString& name);
virtual WebKit::WebWidget* createPopupMenu(WebKit::WebPopupType popup_type); virtual WebKit::WebWidget* createPopupMenu(WebKit::WebPopupType popup_type);
virtual WebKit::WebWidget* createPopupMenu( virtual WebKit::WebWidget* createPopupMenu(
const WebKit::WebPopupMenuInfo& info); const WebKit::WebPopupMenuInfo& info);
virtual WebKit::WebStorageNamespace* createSessionStorageNamespace( virtual WebKit::WebStorageNamespace* createSessionStorageNamespace(
unsigned quota); unsigned quota);
virtual void didAddMessageToConsole( virtual void didAddMessageToConsole(
const WebKit::WebConsoleMessage& message, const WebKit::WebConsoleMessage& message,
const WebKit::WebString& source_name, unsigned source_line); const WebKit::WebString& source_name, unsigned source_line);
virtual void printPage(WebKit::WebFrame* frame); virtual void printPage(WebKit::WebFrame* frame);
virtual void didStartLoading(); virtual void didStartLoading();
virtual void didStopLoading(); virtual void didStopLoading();
virtual bool shouldBeginEditing(const WebKit::WebRange& range); virtual bool shouldBeginEditing(const WebKit::WebRange& range);
virtual bool shouldEndEditing(const WebKit::WebRange& range); virtual bool shouldEndEditing(const WebKit::WebRange& range);
virtual bool shouldInsertNode( virtual bool shouldInsertNode(
const WebKit::WebNode& node, const WebKit::WebRange& range, const WebKit::WebNode& node, const WebKit::WebRange& range,
WebKit::WebEditingAction action); WebKit::WebEditingAction action);
virtual bool shouldInsertText( virtual bool shouldInsertText(
const WebKit::WebString& text, const WebKit::WebRange& range, const WebKit::WebString& text, const WebKit::WebRange& range,
WebKit::WebEditingAction action); WebKit::WebEditingAction action);
virtual bool shouldChangeSelectedRange( virtual bool shouldChangeSelectedRange(
const WebKit::WebRange& from, const WebKit::WebRange& to, const WebKit::WebRange& from, const WebKit::WebRange& to,
WebKit::WebTextAffinity affinity, bool still_selecting); WebKit::WebTextAffinity affinity, bool still_selecting);
virtual bool shouldDeleteRange(const WebKit::WebRange& range); virtual bool shouldDeleteRange(const WebKit::WebRange& range);
virtual bool shouldApplyStyle( virtual bool shouldApplyStyle(
const WebKit::WebString& style, const WebKit::WebRange& range); const WebKit::WebString& style, const WebKit::WebRange& range);
virtual bool isSmartInsertDeleteEnabled(); virtual bool isSmartInsertDeleteEnabled();
virtual bool isSelectTrailingWhitespaceEnabled(); virtual bool isSelectTrailingWhitespaceEnabled();
virtual bool handleCurrentKeyboardEvent(); virtual bool handleCurrentKeyboardEvent();
virtual bool runFileChooser( virtual bool runFileChooser(
const WebKit::WebFileChooserParams& params, const WebKit::WebFileChooserParams& params,
WebKit::WebFileChooserCompletion* chooser_completion); WebKit::WebFileChooserCompletion* chooser_completion);
virtual void runModalAlertDialog( virtual void runModalAlertDialog(
WebKit::WebFrame* frame, const WebKit::WebString& message); WebKit::WebFrame* frame, const WebKit::WebString& message);
virtual bool runModalConfirmDialog( virtual bool runModalConfirmDialog(
WebKit::WebFrame* frame, const WebKit::WebString& message); WebKit::WebFrame* frame, const WebKit::WebString& message);
virtual bool runModalPromptDialog( virtual bool runModalPromptDialog(
WebKit::WebFrame* frame, const WebKit::WebString& message, WebKit::WebFrame* frame, const WebKit::WebString& message,
const WebKit::WebString& default_value, WebKit::WebString* actual_value); const WebKit::WebString& default_value, WebKit::WebString* actual_value);
virtual bool runModalBeforeUnloadDialog( virtual bool runModalBeforeUnloadDialog(
WebKit::WebFrame* frame, const WebKit::WebString& message); WebKit::WebFrame* frame, const WebKit::WebString& message);
virtual void showContextMenu( virtual void showContextMenu(
WebKit::WebFrame* frame, const WebKit::WebContextMenuData& data); WebKit::WebFrame* frame, const WebKit::WebContextMenuData& data);
virtual void setStatusText(const WebKit::WebString& text); virtual void setStatusText(const WebKit::WebString& text);
virtual void setMouseOverURL(const WebKit::WebURL& url); virtual void setMouseOverURL(const WebKit::WebURL& url);
virtual void setKeyboardFocusURL(const WebKit::WebURL& url); virtual void setKeyboardFocusURL(const WebKit::WebURL& url);
virtual void setToolTipText( virtual void setToolTipText(
const WebKit::WebString& text, WebKit::WebTextDirection hint); const WebKit::WebString& text, WebKit::WebTextDirection hint);
virtual void startDragging( virtual void startDragging(
const WebKit::WebDragData& data, const WebKit::WebDragData& data,
WebKit::WebDragOperationsMask mask, WebKit::WebDragOperationsMask mask,
const WebKit::WebImage& image, const WebKit::WebImage& image,
const WebKit::WebPoint& image_offset); const WebKit::WebPoint& image_offset);
virtual bool acceptsLoadDrops() { return true; } virtual bool acceptsLoadDrops() { return true; }
virtual void focusNext(); virtual void focusNext();
virtual void focusPrevious(); virtual void focusPrevious();
virtual void navigateBackForwardSoon(int offset); virtual void navigateBackForwardSoon(int offset);
virtual int historyBackListCount(); virtual int historyBackListCount();
virtual int historyForwardListCount(); virtual int historyForwardListCount();
// WebKit::WebWidgetClient // WebKit::WebWidgetClient
virtual void didInvalidateRect(const WebKit::WebRect& rect); virtual void didInvalidateRect(const WebKit::WebRect& rect);
virtual void didScrollRect(int dx, int dy, virtual void didScrollRect(int dx, int dy,
const WebKit::WebRect& clip_rect); const WebKit::WebRect& clip_rect);
virtual void scheduleComposite(); virtual void scheduleComposite();
virtual void didFocus(); virtual void didFocus();
virtual void didBlur(); virtual void didBlur();
virtual void didChangeCursor(const WebKit::WebCursorInfo& cursor); virtual void didChangeCursor(const WebKit::WebCursorInfo& cursor);
virtual void closeWidgetSoon(); virtual void closeWidgetSoon();
virtual void show(WebKit::WebNavigationPolicy policy); virtual void show(WebKit::WebNavigationPolicy policy);
virtual void runModal(); virtual void runModal();
virtual WebKit::WebRect windowRect(); virtual WebKit::WebRect windowRect();
virtual void setWindowRect(const WebKit::WebRect& rect); virtual void setWindowRect(const WebKit::WebRect& rect);
virtual WebKit::WebRect rootWindowRect(); virtual WebKit::WebRect rootWindowRect();
virtual WebKit::WebRect windowResizerRect(); virtual WebKit::WebRect windowResizerRect();
virtual WebKit::WebScreenInfo screenInfo(); virtual WebKit::WebScreenInfo screenInfo();
// WebKit::WebFrameClient // WebKit::WebFrameClient
virtual WebKit::WebPlugin* createPlugin( virtual WebKit::WebPlugin* createPlugin(
WebKit::WebFrame*, const WebKit::WebPluginParams&); WebKit::WebFrame*, const WebKit::WebPluginParams&);
virtual WebKit::WebMediaPlayer* createMediaPlayer( virtual WebKit::WebMediaPlayer* createMediaPlayer(
WebKit::WebFrame*, WebKit::WebMediaPlayerClient*); WebKit::WebFrame*, WebKit::WebMediaPlayerClient*);
virtual WebKit::WebApplicationCacheHost* createApplicationCacheHost( virtual WebKit::WebApplicationCacheHost* createApplicationCacheHost(
WebKit::WebFrame* frame, WebKit::WebApplicationCacheHostClient* client); WebKit::WebFrame* frame, WebKit::WebApplicationCacheHostClient* client);
virtual void loadURLExternally( virtual void loadURLExternally(
WebKit::WebFrame*, const WebKit::WebURLRequest&, WebKit::WebFrame*, const WebKit::WebURLRequest&,
WebKit::WebNavigationPolicy); WebKit::WebNavigationPolicy);
virtual WebKit::WebNavigationPolicy decidePolicyForNavigation( virtual WebKit::WebNavigationPolicy decidePolicyForNavigation(
WebKit::WebFrame*, const WebKit::WebURLRequest&, WebKit::WebFrame*, const WebKit::WebURLRequest&,
WebKit::WebNavigationType, const WebKit::WebNode&, WebKit::WebNavigationType, const WebKit::WebNode&,
WebKit::WebNavigationPolicy default_policy, bool isRedirect); WebKit::WebNavigationPolicy default_policy, bool isRedirect);
virtual bool canHandleRequest( virtual bool canHandleRequest(
WebKit::WebFrame*, const WebKit::WebURLRequest&) { return true; } WebKit::WebFrame*, const WebKit::WebURLRequest&) { return true; }
virtual WebKit::WebURLError cannotHandleRequestError( virtual WebKit::WebURLError cannotHandleRequestError(
WebKit::WebFrame*, const WebKit::WebURLRequest& request); WebKit::WebFrame*, const WebKit::WebURLRequest& request);
virtual WebKit::WebURLError cancelledError( virtual WebKit::WebURLError cancelledError(
WebKit::WebFrame*, const WebKit::WebURLRequest& request); WebKit::WebFrame*, const WebKit::WebURLRequest& request);
virtual void didCreateDataSource( virtual void didCreateDataSource(
WebKit::WebFrame*, WebKit::WebDataSource*); WebKit::WebFrame*, WebKit::WebDataSource*);
virtual void didStartProvisionalLoad(WebKit::WebFrame*); virtual void didStartProvisionalLoad(WebKit::WebFrame*);
virtual void didReceiveServerRedirectForProvisionalLoad(WebKit::WebFrame*); virtual void didReceiveServerRedirectForProvisionalLoad(WebKit::WebFrame*);
virtual void didFailProvisionalLoad( virtual void didFailProvisionalLoad(
WebKit::WebFrame*, const WebKit::WebURLError&); WebKit::WebFrame*, const WebKit::WebURLError&);
virtual void didCommitProvisionalLoad( virtual void didCommitProvisionalLoad(
WebKit::WebFrame*, bool is_new_navigation); WebKit::WebFrame*, bool is_new_navigation);
virtual void didClearWindowObject(WebKit::WebFrame*); virtual void didClearWindowObject(WebKit::WebFrame*);
virtual void didReceiveTitle( virtual void didReceiveTitle(
WebKit::WebFrame*, const WebKit::WebString& title); WebKit::WebFrame*, const WebKit::WebString& title);
virtual void didFailLoad( virtual void didFailLoad(
WebKit::WebFrame*, const WebKit::WebURLError&); WebKit::WebFrame*, const WebKit::WebURLError&);
virtual void didFinishLoad(WebKit::WebFrame*); virtual void didFinishLoad(WebKit::WebFrame*);
virtual void didChangeLocationWithinPage( virtual void didChangeLocationWithinPage(
WebKit::WebFrame*, bool isNewNavigation); WebKit::WebFrame*, bool isNewNavigation);
virtual void willSendRequest( virtual void willSendRequest(
WebKit::WebFrame*, unsigned identifier, WebKit::WebURLRequest&, WebKit::WebFrame*, unsigned identifier, WebKit::WebURLRequest&,
const WebKit::WebURLResponse& redirectResponse); const WebKit::WebURLResponse& redirectResponse);
virtual void reportFindInPageMatchCount( virtual void reportFindInPageMatchCount(
int request_id, int count, bool final_update); int request_id, int count, bool final_update);
virtual void reportFindInPageSelection( virtual void reportFindInPageSelection(
int request_id, int active_match_ordinal, const WebKit::WebRect& sel); int request_id, int active_match_ordinal, const WebKit::WebRect& sel);
virtual void openFileSystem( virtual void openFileSystem(
WebKit::WebFrame* frame, WebKit::WebFrame* frame,
WebKit::WebFileSystem::Type type, WebKit::WebFileSystem::Type type,
long long size, long long size,
WebKit::WebFileSystemCallbacks* callbacks); WebKit::WebFileSystemCallbacks* callbacks);
// webkit_glue::WebPluginPageDelegate // webkit_glue::WebPluginPageDelegate
virtual webkit_glue::WebPluginDelegate* CreatePluginDelegate( virtual webkit_glue::WebPluginDelegate* CreatePluginDelegate(
const FilePath& file_path, const FilePath& file_path,
const std::string& mime_type); const std::string& mime_type);
virtual void CreatedPluginWindow( virtual void CreatedPluginWindow(
gfx::PluginWindowHandle handle); gfx::PluginWindowHandle handle);
virtual void WillDestroyPluginWindow( virtual void WillDestroyPluginWindow(
gfx::PluginWindowHandle handle); gfx::PluginWindowHandle handle);
virtual void DidMovePlugin( virtual void DidMovePlugin(
const webkit_glue::WebPluginGeometry& move); const webkit_glue::WebPluginGeometry& move);
virtual void DidStartLoadingForPlugin() {} virtual void DidStartLoadingForPlugin() {}
virtual void DidStopLoadingForPlugin() {} virtual void DidStopLoadingForPlugin() {}
virtual void ShowModalHTMLDialogForPlugin( virtual void ShowModalHTMLDialogForPlugin(
const GURL& url, const GURL& url,
const gfx::Size& size, const gfx::Size& size,
const std::string& json_arguments, const std::string& json_arguments,
std::string* json_retval) {} std::string* json_retval) {}
virtual WebKit::WebCookieJar* GetCookieJar(); virtual WebKit::WebCookieJar* GetCookieJar();
BrowserWebViewDelegate(CefBrowserImpl* browser); BrowserWebViewDelegate(CefBrowserImpl* browser);
~BrowserWebViewDelegate(); ~BrowserWebViewDelegate();
void Reset(); void Reset();
void SetSmartInsertDeleteEnabled(bool enabled); void SetSmartInsertDeleteEnabled(bool enabled);
void SetSelectTrailingWhitespaceEnabled(bool enabled); void SetSelectTrailingWhitespaceEnabled(bool enabled);
// Additional accessors // Additional accessors
WebKit::WebFrame* top_loading_frame() { return top_loading_frame_; } WebKit::WebFrame* top_loading_frame() { return top_loading_frame_; }
#if defined(OS_WIN) #if defined(OS_WIN)
IDropTarget* drop_delegate() { return drop_delegate_.get(); } IDropTarget* drop_delegate() { return drop_delegate_.get(); }
IDropSource* drag_delegate() { return drag_delegate_.get(); } IDropSource* drag_delegate() { return drag_delegate_.get(); }
#endif #endif
void set_pending_extra_data(BrowserExtraData* extra_data) { void set_pending_extra_data(BrowserExtraData* extra_data) {
pending_extra_data_.reset(extra_data); pending_extra_data_.reset(extra_data);
} }
// Methods for modifying WebPreferences // Methods for modifying WebPreferences
void SetUserStyleSheetEnabled(bool is_enabled); void SetUserStyleSheetEnabled(bool is_enabled);
void SetUserStyleSheetLocation(const GURL& location); void SetUserStyleSheetLocation(const GURL& location);
// Sets the webview as a drop target. // Sets the webview as a drop target.
void RegisterDragDrop(); void RegisterDragDrop();
void RevokeDragDrop(); void RevokeDragDrop();
void ResetDragDrop(); void ResetDragDrop();
void SetCustomPolicyDelegate(bool is_custom, bool is_permissive); void SetCustomPolicyDelegate(bool is_custom, bool is_permissive);
void WaitForPolicyDelegate(); void WaitForPolicyDelegate();
void set_block_redirects(bool block_redirects) { void set_block_redirects(bool block_redirects) {
block_redirects_ = block_redirects; block_redirects_ = block_redirects;
} }
bool block_redirects() const { bool block_redirects() const {
return block_redirects_; return block_redirects_;
} }
void SetEditCommand(const std::string& name, const std::string& value) { void SetEditCommand(const std::string& name, const std::string& value) {
edit_command_name_ = name; edit_command_name_ = name;
edit_command_value_ = value; edit_command_value_ = value;
} }
void ClearEditCommand() { void ClearEditCommand() {
edit_command_name_.clear(); edit_command_name_.clear();
edit_command_value_.clear(); edit_command_value_.clear();
} }
CefBrowserImpl* GetBrowser() { return browser_; } CefBrowserImpl* GetBrowser() { return browser_; }
protected: protected:
// Called when the URL of the page changes. // Called when the URL of the page changes.
void UpdateAddressBar(WebKit::WebView* webView); void UpdateAddressBar(WebKit::WebView* webView);
// Default handling of JavaScript messages. // Default handling of JavaScript messages.
void ShowJavaScriptAlert(WebKit::WebFrame* webframe, void ShowJavaScriptAlert(WebKit::WebFrame* webframe,
const std::wstring& message); const std::wstring& message);
bool ShowJavaScriptConfirm(WebKit::WebFrame* webframe, bool ShowJavaScriptConfirm(WebKit::WebFrame* webframe,
const std::wstring& message); const std::wstring& message);
bool ShowJavaScriptPrompt(WebKit::WebFrame* webframe, bool ShowJavaScriptPrompt(WebKit::WebFrame* webframe,
const std::wstring& message, const std::wstring& message,
const std::wstring& default_value, const std::wstring& default_value,
std::wstring* result); std::wstring* result);
// Called to show the file chooser dialog. // Called to show the file chooser dialog.
bool ShowFileChooser(std::vector<FilePath>& file_names, bool ShowFileChooser(std::vector<FilePath>& file_names,
const bool multi_select, const bool multi_select,
const WebKit::WebString& title, const WebKit::WebString& title,
const FilePath& default_file); const FilePath& default_file);
// In the Mac code, this is called to trigger the end of a test after the // In the Mac code, this is called to trigger the end of a test after the
// page has finished loading. From here, we can generate the dump for the // page has finished loading. From here, we can generate the dump for the
// test. // test.
void LocationChangeDone(WebKit::WebFrame*); void LocationChangeDone(WebKit::WebFrame*);
WebWidgetHost* GetWidgetHost(); WebWidgetHost* GetWidgetHost();
void UpdateForCommittedLoad(WebKit::WebFrame* webframe, void UpdateForCommittedLoad(WebKit::WebFrame* webframe,
bool is_new_navigation); bool is_new_navigation);
void UpdateURL(WebKit::WebFrame* frame); void UpdateURL(WebKit::WebFrame* frame);
void UpdateSessionHistory(WebKit::WebFrame* frame); void UpdateSessionHistory(WebKit::WebFrame* frame);
private: private:
// Causes navigation actions just printout the intended navigation instead // Causes navigation actions just printout the intended navigation instead
// of taking you to the page. This is used for cases like mailto, where you // of taking you to the page. This is used for cases like mailto, where you
// don't actually want to open the mail program. // don't actually want to open the mail program.
bool policy_delegate_enabled_; bool policy_delegate_enabled_;
// Toggles the behavior of the policy delegate. If true, then navigations // Toggles the behavior of the policy delegate. If true, then navigations
// will be allowed. Otherwise, they will be ignored (dropped). // will be allowed. Otherwise, they will be ignored (dropped).
bool policy_delegate_is_permissive_; bool policy_delegate_is_permissive_;
// If true, the policy delegate will signal layout test completion. // If true, the policy delegate will signal layout test completion.
bool policy_delegate_should_notify_done_; bool policy_delegate_should_notify_done_;
// Non-owning pointer. The delegate is owned by the host. // Non-owning pointer. The delegate is owned by the host.
CefBrowserImpl* browser_; CefBrowserImpl* browser_;
// This is non-NULL IFF a load is in progress. // This is non-NULL IFF a load is in progress.
WebKit::WebFrame* top_loading_frame_; WebKit::WebFrame* top_loading_frame_;
// For tracking session history. See RenderView. // For tracking session history. See RenderView.
int page_id_; int page_id_;
int last_page_id_updated_; int last_page_id_updated_;
scoped_ptr<BrowserExtraData> pending_extra_data_; scoped_ptr<BrowserExtraData> pending_extra_data_;
WebCursor current_cursor_; WebCursor current_cursor_;
#if defined(OS_WIN) #if defined(OS_WIN)
// Classes needed by drag and drop. // Classes needed by drag and drop.
scoped_refptr<BrowserDragDelegate> drag_delegate_; scoped_refptr<BrowserDragDelegate> drag_delegate_;
scoped_refptr<BrowserDropDelegate> drop_delegate_; scoped_refptr<BrowserDropDelegate> drop_delegate_;
#endif #endif
#if defined(OS_LINUX) #if defined(OS_LINUX)
// The type of cursor the window is currently using. // The type of cursor the window is currently using.
// Used for judging whether a new SetCursor call is actually changing the // Used for judging whether a new SetCursor call is actually changing the
// cursor. // cursor.
GdkCursorType cursor_type_; GdkCursorType cursor_type_;
#endif #endif
// true if we want to enable smart insert/delete. // true if we want to enable smart insert/delete.
bool smart_insert_delete_enabled_; bool smart_insert_delete_enabled_;
// true if we want to enable selection of trailing whitespaces // true if we want to enable selection of trailing whitespaces
bool select_trailing_whitespace_enabled_; bool select_trailing_whitespace_enabled_;
// true if we should block any redirects // true if we should block any redirects
bool block_redirects_; bool block_redirects_;
// Edit command associated to the current keyboard event. // Edit command associated to the current keyboard event.
std::string edit_command_name_; std::string edit_command_name_;
std::string edit_command_value_; std::string edit_command_value_;
DISALLOW_COPY_AND_ASSIGN(BrowserWebViewDelegate); DISALLOW_COPY_AND_ASSIGN(BrowserWebViewDelegate);
}; };
#endif // _BROWSER_WEBVIEW_DELEGATE_H #endif // _BROWSER_WEBVIEW_DELEGATE_H

File diff suppressed because it is too large Load Diff

View File

@ -1,324 +1,324 @@
// Copyright (c) 2010 The Chromium Embedded Framework Authors. All rights // Copyright (c) 2010 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that can // reserved. Use of this source code is governed by a BSD-style license that can
// be found in the LICENSE file. // be found in the LICENSE file.
#include "cef_context.h" #include "cef_context.h"
#include "browser_impl.h" #include "browser_impl.h"
#include "browser_webkit_glue.h" #include "browser_webkit_glue.h"
#include "cef_thread.h" #include "cef_thread.h"
#include "cef_process.h" #include "cef_process.h"
#include "../include/cef_nplugin.h" #include "../include/cef_nplugin.h"
#include "base/file_util.h" #include "base/file_util.h"
#if defined(OS_MACOSX) || defined(OS_WIN) #if defined(OS_MACOSX) || defined(OS_WIN)
#include "base/nss_util.h" #include "base/nss_util.h"
#endif #endif
#include "webkit/glue/plugins/plugin_list.h" #include "webkit/glue/plugins/plugin_list.h"
#include "webkit/glue/webpreferences.h" #include "webkit/glue/webpreferences.h"
// Global CefContext pointer // Global CefContext pointer
CefRefPtr<CefContext> _Context; CefRefPtr<CefContext> _Context;
bool CefInitialize(bool multi_threaded_message_loop, bool CefInitialize(bool multi_threaded_message_loop,
const std::wstring& cache_path) const std::wstring& cache_path)
{ {
// Return true if the context is already initialized // Return true if the context is already initialized
if(_Context.get()) if(_Context.get())
return true; return true;
// Create the new global context object // Create the new global context object
_Context = new CefContext(); _Context = new CefContext();
// Initialize the global context // Initialize the global context
return _Context->Initialize(multi_threaded_message_loop, cache_path); return _Context->Initialize(multi_threaded_message_loop, cache_path);
} }
void CefShutdown() void CefShutdown()
{ {
// Verify that the context is already initialized // Verify that the context is already initialized
if(!_Context.get()) if(!_Context.get())
return; return;
// Shut down the global context // Shut down the global context
_Context->Shutdown(); _Context->Shutdown();
// Delete the global context object // Delete the global context object
_Context = NULL; _Context = NULL;
} }
void CefDoMessageLoopWork() void CefDoMessageLoopWork()
{ {
// Verify that the context is already initialized. // Verify that the context is already initialized.
if(!_Context.get() || !_Context->process()) if(!_Context.get() || !_Context->process())
return; return;
if(!_Context->process()->CalledOnValidThread()) if(!_Context->process()->CalledOnValidThread())
return; return;
_Context->process()->DoMessageLoopIteration(); _Context->process()->DoMessageLoopIteration();
} }
static void UIT_RegisterPlugin(struct CefPluginInfo* plugin_info) static void UIT_RegisterPlugin(struct CefPluginInfo* plugin_info)
{ {
REQUIRE_UIT(); REQUIRE_UIT();
NPAPI::PluginVersionInfo info; NPAPI::PluginVersionInfo info;
info.path = FilePath(plugin_info->unique_name); info.path = FilePath(plugin_info->unique_name);
info.product_name = plugin_info->display_name; info.product_name = plugin_info->display_name;
info.file_description = plugin_info->description; info.file_description = plugin_info->description;
info.file_version =plugin_info->version; info.file_version =plugin_info->version;
for(size_t i = 0; i < plugin_info->mime_types.size(); ++i) { for(size_t i = 0; i < plugin_info->mime_types.size(); ++i) {
if(i > 0) { if(i > 0) {
info.mime_types += L"|"; info.mime_types += L"|";
info.file_extensions += L"|"; info.file_extensions += L"|";
info.type_descriptions += L"|"; info.type_descriptions += L"|";
} }
info.mime_types += plugin_info->mime_types[i].mime_type; info.mime_types += plugin_info->mime_types[i].mime_type;
info.type_descriptions += plugin_info->mime_types[i].description; info.type_descriptions += plugin_info->mime_types[i].description;
for(size_t j = 0; for(size_t j = 0;
j < plugin_info->mime_types[i].file_extensions.size(); ++j) { j < plugin_info->mime_types[i].file_extensions.size(); ++j) {
if(j > 0) { if(j > 0) {
info.file_extensions += L","; info.file_extensions += L",";
} }
info.file_extensions += plugin_info->mime_types[i].file_extensions[j]; info.file_extensions += plugin_info->mime_types[i].file_extensions[j];
} }
} }
info.entry_points.np_getentrypoints = plugin_info->np_getentrypoints; info.entry_points.np_getentrypoints = plugin_info->np_getentrypoints;
info.entry_points.np_initialize = plugin_info->np_initialize; info.entry_points.np_initialize = plugin_info->np_initialize;
info.entry_points.np_shutdown = plugin_info->np_shutdown; info.entry_points.np_shutdown = plugin_info->np_shutdown;
NPAPI::PluginList::Singleton()->RegisterInternalPlugin(info); NPAPI::PluginList::Singleton()->RegisterInternalPlugin(info);
delete plugin_info; delete plugin_info;
} }
bool CefRegisterPlugin(const struct CefPluginInfo& plugin_info) bool CefRegisterPlugin(const struct CefPluginInfo& plugin_info)
{ {
if(!_Context.get()) if(!_Context.get())
return false; return false;
CefPluginInfo* pPluginInfo = new CefPluginInfo; CefPluginInfo* pPluginInfo = new CefPluginInfo;
*pPluginInfo = plugin_info; *pPluginInfo = plugin_info;
CefThread::PostTask(CefThread::UI, FROM_HERE, CefThread::PostTask(CefThread::UI, FROM_HERE,
NewRunnableFunction(UIT_RegisterPlugin, pPluginInfo)); NewRunnableFunction(UIT_RegisterPlugin, pPluginInfo));
return true; return true;
} }
static int GetThreadId(CefThreadId threadId) static int GetThreadId(CefThreadId threadId)
{ {
switch(threadId) { switch(threadId) {
case TID_UI: return CefThread::UI; case TID_UI: return CefThread::UI;
case TID_IO: return CefThread::IO; case TID_IO: return CefThread::IO;
case TID_FILE: return CefThread::FILE; case TID_FILE: return CefThread::FILE;
}; };
NOTREACHED(); NOTREACHED();
return -1; return -1;
} }
bool CefCurrentlyOn(CefThreadId threadId) bool CefCurrentlyOn(CefThreadId threadId)
{ {
int id = GetThreadId(threadId); int id = GetThreadId(threadId);
if(id < 0) if(id < 0)
return false; return false;
return CefThread::CurrentlyOn(static_cast<CefThread::ID>(id)); return CefThread::CurrentlyOn(static_cast<CefThread::ID>(id));
} }
class CefTaskHelper : public base::RefCountedThreadSafe<CefTaskHelper> class CefTaskHelper : public base::RefCountedThreadSafe<CefTaskHelper>
{ {
public: public:
CefTaskHelper(CefRefPtr<CefTask> task) : task_(task) {} CefTaskHelper(CefRefPtr<CefTask> task) : task_(task) {}
void Execute(CefThreadId threadId) { task_->Execute(threadId); } void Execute(CefThreadId threadId) { task_->Execute(threadId); }
private: private:
CefRefPtr<CefTask> task_; CefRefPtr<CefTask> task_;
DISALLOW_COPY_AND_ASSIGN(CefTaskHelper); DISALLOW_COPY_AND_ASSIGN(CefTaskHelper);
}; };
bool CefPostTask(CefThreadId threadId, CefRefPtr<CefTask> task) bool CefPostTask(CefThreadId threadId, CefRefPtr<CefTask> task)
{ {
int id = GetThreadId(threadId); int id = GetThreadId(threadId);
if(id < 0) if(id < 0)
return false; return false;
scoped_refptr<CefTaskHelper> helper(new CefTaskHelper(task)); scoped_refptr<CefTaskHelper> helper(new CefTaskHelper(task));
return CefThread::PostTask(static_cast<CefThread::ID>(id), FROM_HERE, return CefThread::PostTask(static_cast<CefThread::ID>(id), FROM_HERE,
NewRunnableMethod(helper.get(), &CefTaskHelper::Execute, threadId)); NewRunnableMethod(helper.get(), &CefTaskHelper::Execute, threadId));
} }
bool CefPostDelayedTask(CefThreadId threadId, CefRefPtr<CefTask> task, bool CefPostDelayedTask(CefThreadId threadId, CefRefPtr<CefTask> task,
long delay_ms) long delay_ms)
{ {
int id = GetThreadId(threadId); int id = GetThreadId(threadId);
if(id < 0) if(id < 0)
return false; return false;
scoped_refptr<CefTaskHelper> helper(new CefTaskHelper(task)); scoped_refptr<CefTaskHelper> helper(new CefTaskHelper(task));
return CefThread::PostDelayedTask(static_cast<CefThread::ID>(id), FROM_HERE, return CefThread::PostDelayedTask(static_cast<CefThread::ID>(id), FROM_HERE,
NewRunnableMethod(helper.get(), &CefTaskHelper::Execute, threadId), NewRunnableMethod(helper.get(), &CefTaskHelper::Execute, threadId),
delay_ms); delay_ms);
} }
// CefContext // CefContext
CefContext::CefContext() : process_(NULL), webprefs_(NULL) CefContext::CefContext() : process_(NULL), webprefs_(NULL)
{ {
} }
CefContext::~CefContext() CefContext::~CefContext()
{ {
// Just in case CefShutdown() isn't called // Just in case CefShutdown() isn't called
Shutdown(); Shutdown();
} }
bool CefContext::Initialize(bool multi_threaded_message_loop, bool CefContext::Initialize(bool multi_threaded_message_loop,
const std::wstring& cache_path) const std::wstring& cache_path)
{ {
cache_path_ = cache_path; cache_path_ = cache_path;
// Initialize web preferences // Initialize web preferences
webprefs_ = new WebPreferences; webprefs_ = new WebPreferences;
*webprefs_ = WebPreferences(); *webprefs_ = WebPreferences();
webprefs_->standard_font_family = L"Times"; webprefs_->standard_font_family = L"Times";
webprefs_->fixed_font_family = L"Courier"; webprefs_->fixed_font_family = L"Courier";
webprefs_->serif_font_family = L"Times"; webprefs_->serif_font_family = L"Times";
webprefs_->sans_serif_font_family = L"Helvetica"; webprefs_->sans_serif_font_family = L"Helvetica";
// These two fonts are picked from the intersection of // These two fonts are picked from the intersection of
// Win XP font list and Vista font list : // Win XP font list and Vista font list :
// http://www.microsoft.com/typography/fonts/winxp.htm // http://www.microsoft.com/typography/fonts/winxp.htm
// http://blogs.msdn.com/michkap/archive/2006/04/04/567881.aspx // http://blogs.msdn.com/michkap/archive/2006/04/04/567881.aspx
// Some of them are installed only with CJK and complex script // Some of them are installed only with CJK and complex script
// support enabled on Windows XP and are out of consideration here. // support enabled on Windows XP and are out of consideration here.
// (although we enabled both on our buildbots.) // (although we enabled both on our buildbots.)
// They (especially Impact for fantasy) are not typical cursive // They (especially Impact for fantasy) are not typical cursive
// and fantasy fonts, but it should not matter for layout tests // and fantasy fonts, but it should not matter for layout tests
// as long as they're available. // as long as they're available.
#if defined(OS_MACOSX) #if defined(OS_MACOSX)
webprefs_->cursive_font_family = L"Apple Chancery"; webprefs_->cursive_font_family = L"Apple Chancery";
webprefs_->fantasy_font_family = L"Papyrus"; webprefs_->fantasy_font_family = L"Papyrus";
#else #else
webprefs_->cursive_font_family = L"Comic Sans MS"; webprefs_->cursive_font_family = L"Comic Sans MS";
webprefs_->fantasy_font_family = L"Impact"; webprefs_->fantasy_font_family = L"Impact";
#endif #endif
webprefs_->default_encoding = "ISO-8859-1"; webprefs_->default_encoding = "ISO-8859-1";
webprefs_->default_font_size = 16; webprefs_->default_font_size = 16;
webprefs_->default_fixed_font_size = 13; webprefs_->default_fixed_font_size = 13;
webprefs_->minimum_font_size = 1; webprefs_->minimum_font_size = 1;
webprefs_->minimum_logical_font_size = 9; webprefs_->minimum_logical_font_size = 9;
webprefs_->javascript_can_open_windows_automatically = true; webprefs_->javascript_can_open_windows_automatically = true;
webprefs_->dom_paste_enabled = true; webprefs_->dom_paste_enabled = true;
webprefs_->developer_extras_enabled = true; webprefs_->developer_extras_enabled = true;
webprefs_->site_specific_quirks_enabled = true; webprefs_->site_specific_quirks_enabled = true;
webprefs_->shrinks_standalone_images_to_fit = false; webprefs_->shrinks_standalone_images_to_fit = false;
webprefs_->uses_universal_detector = false; webprefs_->uses_universal_detector = false;
webprefs_->text_areas_are_resizable = true; webprefs_->text_areas_are_resizable = true;
webprefs_->java_enabled = true; webprefs_->java_enabled = true;
webprefs_->allow_scripts_to_close_windows = false; webprefs_->allow_scripts_to_close_windows = false;
webprefs_->xss_auditor_enabled = false; webprefs_->xss_auditor_enabled = false;
webprefs_->remote_fonts_enabled = true; webprefs_->remote_fonts_enabled = true;
webprefs_->local_storage_enabled = true; webprefs_->local_storage_enabled = true;
webprefs_->application_cache_enabled = true; webprefs_->application_cache_enabled = true;
webprefs_->databases_enabled = true; webprefs_->databases_enabled = true;
webprefs_->allow_file_access_from_file_urls = true; webprefs_->allow_file_access_from_file_urls = true;
webprefs_->accelerated_2d_canvas_enabled = true; webprefs_->accelerated_2d_canvas_enabled = true;
webprefs_->accelerated_compositing_enabled = true; webprefs_->accelerated_compositing_enabled = true;
#if defined(OS_MACOSX) || defined(OS_WIN) #if defined(OS_MACOSX) || defined(OS_WIN)
// We want to be sure to init NSPR on the main thread. // We want to be sure to init NSPR on the main thread.
base::EnsureNSPRInit(); base::EnsureNSPRInit();
#endif #endif
process_ = new CefProcess(multi_threaded_message_loop); process_ = new CefProcess(multi_threaded_message_loop);
process_->CreateChildThreads(); process_->CreateChildThreads();
return true; return true;
} }
void CefContext::Shutdown() void CefContext::Shutdown()
{ {
// Remove all existing browsers. // Remove all existing browsers.
//RemoveAllBrowsers(); //RemoveAllBrowsers();
// Deleting the process will destroy the child threads. // Deleting the process will destroy the child threads.
process_ = NULL; process_ = NULL;
} }
bool CefContext::AddBrowser(CefRefPtr<CefBrowserImpl> browser) bool CefContext::AddBrowser(CefRefPtr<CefBrowserImpl> browser)
{ {
bool found = false; bool found = false;
Lock(); Lock();
// check that the browser isn't already in the list before adding // check that the browser isn't already in the list before adding
BrowserList::const_iterator it = browserlist_.begin(); BrowserList::const_iterator it = browserlist_.begin();
for(; it != browserlist_.end(); ++it) { for(; it != browserlist_.end(); ++it) {
if(it->get() == browser.get()) { if(it->get() == browser.get()) {
found = true; found = true;
break; break;
} }
} }
if(!found) if(!found)
{ {
browser->UIT_SetUniqueID(next_browser_id_++); browser->UIT_SetUniqueID(next_browser_id_++);
browserlist_.push_back(browser); browserlist_.push_back(browser);
} }
Unlock(); Unlock();
return !found; return !found;
} }
bool CefContext::RemoveBrowser(CefRefPtr<CefBrowserImpl> browser) bool CefContext::RemoveBrowser(CefRefPtr<CefBrowserImpl> browser)
{ {
bool deleted = false; bool deleted = false;
bool empty = false; bool empty = false;
Lock(); Lock();
BrowserList::iterator it = browserlist_.begin(); BrowserList::iterator it = browserlist_.begin();
for(; it != browserlist_.end(); ++it) { for(; it != browserlist_.end(); ++it) {
if(it->get() == browser.get()) { if(it->get() == browser.get()) {
browserlist_.erase(it); browserlist_.erase(it);
deleted = true; deleted = true;
break; break;
} }
} }
if (browserlist_.empty()) { if (browserlist_.empty()) {
next_browser_id_ = 1; next_browser_id_ = 1;
empty = true; empty = true;
} }
Unlock(); Unlock();
if (empty) { if (empty) {
CefThread::PostTask(CefThread::UI, FROM_HERE, CefThread::PostTask(CefThread::UI, FROM_HERE,
NewRunnableFunction(webkit_glue::ClearCache)); NewRunnableFunction(webkit_glue::ClearCache));
} }
return deleted; return deleted;
} }
CefRefPtr<CefBrowserImpl> CefContext::GetBrowserByID(int id) CefRefPtr<CefBrowserImpl> CefContext::GetBrowserByID(int id)
{ {
CefRefPtr<CefBrowserImpl> browser; CefRefPtr<CefBrowserImpl> browser;
Lock(); Lock();
BrowserList::const_iterator it = browserlist_.begin(); BrowserList::const_iterator it = browserlist_.begin();
for(; it != browserlist_.end(); ++it) { for(; it != browserlist_.end(); ++it) {
if(it->get()->UIT_GetUniqueID() == id) { if(it->get()->UIT_GetUniqueID() == id) {
browser = it->get(); browser = it->get();
break; break;
} }
} }
Unlock(); Unlock();
return browser; return browser;
} }

View File

@ -1,81 +1,81 @@
// Copyright (c) 2010 The Chromium Embedded Framework Authors. All rights // Copyright (c) 2010 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that can // reserved. Use of this source code is governed by a BSD-style license that can
// be found in the LICENSE file. // be found in the LICENSE file.
#ifndef _CEF_CONTEXT_H #ifndef _CEF_CONTEXT_H
#define _CEF_CONTEXT_H #define _CEF_CONTEXT_H
#include "../include/cef.h" #include "../include/cef.h"
#include "browser_request_context.h" #include "browser_request_context.h"
#include "cef_process.h" #include "cef_process.h"
#include "cef_thread.h" #include "cef_thread.h"
#include "base/at_exit.h" #include "base/at_exit.h"
#include "base/file_path.h" #include "base/file_path.h"
#include "base/message_loop.h" #include "base/message_loop.h"
#include "base/ref_counted.h" #include "base/ref_counted.h"
#include <map> #include <map>
class BrowserRequestContext; class BrowserRequestContext;
class CefBrowserImpl; class CefBrowserImpl;
struct WebPreferences; struct WebPreferences;
class CefContext : public CefThreadSafeBase<CefBase> class CefContext : public CefThreadSafeBase<CefBase>
{ {
public: public:
typedef std::list<CefRefPtr<CefBrowserImpl> > BrowserList; typedef std::list<CefRefPtr<CefBrowserImpl> > BrowserList;
CefContext(); CefContext();
~CefContext(); ~CefContext();
// These methods will be called on the main application thread. // These methods will be called on the main application thread.
bool Initialize(bool multi_threaded_message_loop, bool Initialize(bool multi_threaded_message_loop,
const std::wstring& cache_path); const std::wstring& cache_path);
void Shutdown(); void Shutdown();
scoped_refptr<CefProcess> process() { return process_; } scoped_refptr<CefProcess> process() { return process_; }
bool AddBrowser(CefRefPtr<CefBrowserImpl> browser); bool AddBrowser(CefRefPtr<CefBrowserImpl> browser);
bool RemoveBrowser(CefRefPtr<CefBrowserImpl> browser); bool RemoveBrowser(CefRefPtr<CefBrowserImpl> browser);
CefRefPtr<CefBrowserImpl> GetBrowserByID(int id); CefRefPtr<CefBrowserImpl> GetBrowserByID(int id);
BrowserList* GetBrowserList() { return &browserlist_; } BrowserList* GetBrowserList() { return &browserlist_; }
// Retrieve the path at which cache data will be stored on disk. If empty, // Retrieve the path at which cache data will be stored on disk. If empty,
// cache data will be stored in-memory. // cache data will be stored in-memory.
const std::wstring& cache_path() { return cache_path_; } const std::wstring& cache_path() { return cache_path_; }
WebPreferences* web_preferences() WebPreferences* web_preferences()
{ {
REQUIRE_UIT(); REQUIRE_UIT();
return webprefs_; return webprefs_;
} }
// The BrowserRequestContext object is managed by CefProcessIOThread. // The BrowserRequestContext object is managed by CefProcessIOThread.
void set_request_context(BrowserRequestContext* request_context) void set_request_context(BrowserRequestContext* request_context)
{ request_context_ = request_context; } { request_context_ = request_context; }
scoped_refptr<BrowserRequestContext> request_context() scoped_refptr<BrowserRequestContext> request_context()
{ return request_context_; } { return request_context_; }
private: private:
// Manages the various process threads. // Manages the various process threads.
scoped_refptr<CefProcess> process_; scoped_refptr<CefProcess> process_;
// Initialize the AtExitManager on the main application thread to avoid // Initialize the AtExitManager on the main application thread to avoid
// asserts and possible memory leaks. // asserts and possible memory leaks.
base::AtExitManager at_exit_manager_; base::AtExitManager at_exit_manager_;
std::wstring cache_path_; std::wstring cache_path_;
WebPreferences* webprefs_; WebPreferences* webprefs_;
scoped_refptr<BrowserRequestContext> request_context_; scoped_refptr<BrowserRequestContext> request_context_;
// Map of browsers that currently exist. // Map of browsers that currently exist.
BrowserList browserlist_; BrowserList browserlist_;
// Used for assigning unique IDs to browser instances. // Used for assigning unique IDs to browser instances.
int next_browser_id_; int next_browser_id_;
}; };
// Global context object pointer // Global context object pointer
extern CefRefPtr<CefContext> _Context; extern CefRefPtr<CefContext> _Context;
#endif // _CEF_CONTEXT_H #endif // _CEF_CONTEXT_H

View File

@ -1,128 +1,128 @@
// Copyright (c) 2010 The Chromium Embedded Framework Authors. // Copyright (c) 2010 The Chromium Embedded Framework Authors.
// Portions copyright (c) 2010 The Chromium Authors. All rights reserved. // Portions copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "cef_process.h" #include "cef_process.h"
#include "cef_process_io_thread.h" #include "cef_process_io_thread.h"
#include "cef_process_sub_thread.h" #include "cef_process_sub_thread.h"
#include "cef_process_ui_thread.h" #include "cef_process_ui_thread.h"
#include "base/thread.h" #include "base/thread.h"
#include "base/waitable_event.h" #include "base/waitable_event.h"
CefProcess* g_cef_process = NULL; CefProcess* g_cef_process = NULL;
// Class used to process events on the current message loop. // Class used to process events on the current message loop.
class CefMessageLoopForUI : public MessageLoopForUI class CefMessageLoopForUI : public MessageLoopForUI
{ {
typedef MessageLoopForUI inherited; typedef MessageLoopForUI inherited;
public: public:
CefMessageLoopForUI() CefMessageLoopForUI()
{ {
} }
// Returns the MessageLoopForUI of the current thread. // Returns the MessageLoopForUI of the current thread.
static CefMessageLoopForUI* current() { static CefMessageLoopForUI* current() {
MessageLoop* loop = MessageLoop::current(); MessageLoop* loop = MessageLoop::current();
DCHECK_EQ(MessageLoop::TYPE_UI, loop->type()); DCHECK_EQ(MessageLoop::TYPE_UI, loop->type());
return static_cast<CefMessageLoopForUI*>(loop); return static_cast<CefMessageLoopForUI*>(loop);
} }
virtual bool DoIdleWork() { virtual bool DoIdleWork() {
bool valueToRet = inherited::DoIdleWork(); bool valueToRet = inherited::DoIdleWork();
pump_->Quit(); pump_->Quit();
return valueToRet; return valueToRet;
} }
void DoMessageLoopIteration() { void DoMessageLoopIteration() {
Run(NULL); Run(NULL);
} }
private: private:
DISALLOW_COPY_AND_ASSIGN(CefMessageLoopForUI); DISALLOW_COPY_AND_ASSIGN(CefMessageLoopForUI);
}; };
CefProcess::CefProcess(bool multi_threaded_message_loop) CefProcess::CefProcess(bool multi_threaded_message_loop)
: multi_threaded_message_loop_(multi_threaded_message_loop), : multi_threaded_message_loop_(multi_threaded_message_loop),
created_ui_thread_(false), created_ui_thread_(false),
created_io_thread_(false), created_io_thread_(false),
created_file_thread_(false) { created_file_thread_(false) {
g_cef_process = this; g_cef_process = this;
} }
CefProcess::~CefProcess() { CefProcess::~CefProcess() {
// Terminate the IO thread. // Terminate the IO thread.
io_thread_.reset(); io_thread_.reset();
// Terminate the FILE thread. // Terminate the FILE thread.
file_thread_.reset(); file_thread_.reset();
if(!multi_threaded_message_loop_) { if(!multi_threaded_message_loop_) {
// Must explicitly clean up the UI thread. // Must explicitly clean up the UI thread.
ui_thread_->CleanUp(); ui_thread_->CleanUp();
// Terminate the UI thread. // Terminate the UI thread.
ui_thread_.reset(); ui_thread_.reset();
// Terminate the message loop. // Terminate the message loop.
ui_message_loop_.reset(); ui_message_loop_.reset();
} }
g_cef_process = NULL; g_cef_process = NULL;
} }
void CefProcess::DoMessageLoopIteration() { void CefProcess::DoMessageLoopIteration() {
DCHECK(CalledOnValidThread() && ui_message_loop_.get() != NULL); DCHECK(CalledOnValidThread() && ui_message_loop_.get() != NULL);
ui_message_loop_->DoMessageLoopIteration(); ui_message_loop_->DoMessageLoopIteration();
} }
void CefProcess::CreateUIThread() { void CefProcess::CreateUIThread() {
DCHECK(!created_ui_thread_ && ui_thread_.get() == NULL); DCHECK(!created_ui_thread_ && ui_thread_.get() == NULL);
created_ui_thread_ = true; created_ui_thread_ = true;
scoped_ptr<CefProcessUIThread> thread; scoped_ptr<CefProcessUIThread> thread;
if(multi_threaded_message_loop_) { if(multi_threaded_message_loop_) {
// Create the message loop on a new thread. // Create the message loop on a new thread.
thread.reset(new CefProcessUIThread()); thread.reset(new CefProcessUIThread());
base::Thread::Options options; base::Thread::Options options;
options.message_loop_type = MessageLoop::TYPE_UI; options.message_loop_type = MessageLoop::TYPE_UI;
if (!thread->StartWithOptions(options)) if (!thread->StartWithOptions(options))
return; return;
} else { } else {
// Create the message loop on the current (main application) thread. // Create the message loop on the current (main application) thread.
ui_message_loop_.reset(new CefMessageLoopForUI()); ui_message_loop_.reset(new CefMessageLoopForUI());
thread.reset( thread.reset(
new CefProcessUIThread(ui_message_loop_.get())); new CefProcessUIThread(ui_message_loop_.get()));
// Must explicitly initialize the UI thread. // Must explicitly initialize the UI thread.
thread->Init(); thread->Init();
} }
ui_thread_.swap(thread); ui_thread_.swap(thread);
} }
void CefProcess::CreateIOThread() { void CefProcess::CreateIOThread() {
DCHECK(!created_io_thread_ && io_thread_.get() == NULL); DCHECK(!created_io_thread_ && io_thread_.get() == NULL);
created_io_thread_ = true; created_io_thread_ = true;
scoped_ptr<CefProcessIOThread> thread(new CefProcessIOThread()); scoped_ptr<CefProcessIOThread> thread(new CefProcessIOThread());
base::Thread::Options options; base::Thread::Options options;
options.message_loop_type = MessageLoop::TYPE_IO; options.message_loop_type = MessageLoop::TYPE_IO;
if (!thread->StartWithOptions(options)) if (!thread->StartWithOptions(options))
return; return;
io_thread_.swap(thread); io_thread_.swap(thread);
} }
void CefProcess::CreateFileThread() { void CefProcess::CreateFileThread() {
DCHECK(!created_file_thread_ && file_thread_.get() == NULL); DCHECK(!created_file_thread_ && file_thread_.get() == NULL);
created_file_thread_ = true; created_file_thread_ = true;
scoped_ptr<base::Thread> thread(new CefProcessSubThread(CefThread::FILE)); scoped_ptr<base::Thread> thread(new CefProcessSubThread(CefThread::FILE));
base::Thread::Options options; base::Thread::Options options;
options.message_loop_type = MessageLoop::TYPE_IO; options.message_loop_type = MessageLoop::TYPE_IO;
if (!thread->StartWithOptions(options)) if (!thread->StartWithOptions(options))
return; return;
file_thread_.swap(thread); file_thread_.swap(thread);
} }

View File

@ -1,64 +1,64 @@
// Copyright (c) 2010 The Chromium Embedded Framework Authors. // Copyright (c) 2010 The Chromium Embedded Framework Authors.
// Portions copyright (c) 2010 The Chromium Authors. All rights reserved. // Portions copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "cef_process_io_thread.h" #include "cef_process_io_thread.h"
#include "cef_context.h" #include "cef_context.h"
#include "browser_appcache_system.h" #include "browser_appcache_system.h"
#include "browser_resource_loader_bridge.h" #include "browser_resource_loader_bridge.h"
#include "browser_socket_stream_bridge.h" #include "browser_socket_stream_bridge.h"
#include "browser_webblobregistry_impl.h" #include "browser_webblobregistry_impl.h"
#include "build/build_config.h" #include "build/build_config.h"
#if defined(OS_WIN) #if defined(OS_WIN)
#include <Objbase.h> #include <Objbase.h>
#endif #endif
CefProcessIOThread::CefProcessIOThread() CefProcessIOThread::CefProcessIOThread()
: CefThread(CefThread::IO), request_context_(NULL) {} : CefThread(CefThread::IO), request_context_(NULL) {}
CefProcessIOThread::CefProcessIOThread(MessageLoop* message_loop) CefProcessIOThread::CefProcessIOThread(MessageLoop* message_loop)
: CefThread(CefThread::IO, message_loop), request_context_(NULL) {} : CefThread(CefThread::IO, message_loop), request_context_(NULL) {}
CefProcessIOThread::~CefProcessIOThread() { CefProcessIOThread::~CefProcessIOThread() {
// We cannot rely on our base class to stop the thread since we want our // We cannot rely on our base class to stop the thread since we want our
// CleanUp function to run. // CleanUp function to run.
Stop(); Stop();
} }
void CefProcessIOThread::Init() { void CefProcessIOThread::Init() {
#if defined(OS_WIN) #if defined(OS_WIN)
// Initializes the COM library on the current thread. // Initializes the COM library on the current thread.
CoInitialize(NULL); CoInitialize(NULL);
#endif #endif
request_context_ = new BrowserRequestContext(FilePath(_Context->cache_path()), request_context_ = new BrowserRequestContext(FilePath(_Context->cache_path()),
net::HttpCache::NORMAL, false); net::HttpCache::NORMAL, false);
_Context->set_request_context(request_context_); _Context->set_request_context(request_context_);
BrowserAppCacheSystem::InitializeOnIOThread(request_context_); BrowserAppCacheSystem::InitializeOnIOThread(request_context_);
BrowserSocketStreamBridge::InitializeOnIOThread(request_context_); BrowserSocketStreamBridge::InitializeOnIOThread(request_context_);
BrowserWebBlobRegistryImpl::InitializeOnIOThread( BrowserWebBlobRegistryImpl::InitializeOnIOThread(
request_context_->blob_storage_controller()); request_context_->blob_storage_controller());
} }
void CefProcessIOThread::CleanUp() { void CefProcessIOThread::CleanUp() {
// Flush any remaining messages. This ensures that any accumulated // Flush any remaining messages. This ensures that any accumulated
// Task objects get destroyed before we exit, which avoids noise in // Task objects get destroyed before we exit, which avoids noise in
// purify leak-test results. // purify leak-test results.
MessageLoop::current()->RunAllPending(); MessageLoop::current()->RunAllPending();
BrowserSocketStreamBridge::Cleanup(); BrowserSocketStreamBridge::Cleanup();
BrowserWebBlobRegistryImpl::Cleanup(); BrowserWebBlobRegistryImpl::Cleanup();
_Context->set_request_context(NULL); _Context->set_request_context(NULL);
request_context_ = NULL; request_context_ = NULL;
#if defined(OS_WIN) #if defined(OS_WIN)
// Closes the COM library on the current thread. CoInitialize must // Closes the COM library on the current thread. CoInitialize must
// be balanced by a corresponding call to CoUninitialize. // be balanced by a corresponding call to CoUninitialize.
CoUninitialize(); CoUninitialize();
#endif #endif
} }

View File

@ -1,44 +1,44 @@
// Copyright (c) 2010 The Chromium Embedded Framework Authors. // Copyright (c) 2010 The Chromium Embedded Framework Authors.
// Portions copyright (c) 2010 The Chromium Authors. All rights reserved. // Portions copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "cef_process_sub_thread.h" #include "cef_process_sub_thread.h"
#include "build/build_config.h" #include "build/build_config.h"
#if defined(OS_WIN) #if defined(OS_WIN)
#include <Objbase.h> #include <Objbase.h>
#endif #endif
CefProcessSubThread::CefProcessSubThread(CefThread::ID identifier) CefProcessSubThread::CefProcessSubThread(CefThread::ID identifier)
: CefThread(identifier) {} : CefThread(identifier) {}
CefProcessSubThread::CefProcessSubThread(CefThread::ID identifier, CefProcessSubThread::CefProcessSubThread(CefThread::ID identifier,
MessageLoop* message_loop) MessageLoop* message_loop)
: CefThread(identifier, message_loop) {} : CefThread(identifier, message_loop) {}
CefProcessSubThread::~CefProcessSubThread() { CefProcessSubThread::~CefProcessSubThread() {
// We cannot rely on our base class to stop the thread since we want our // We cannot rely on our base class to stop the thread since we want our
// CleanUp function to run. // CleanUp function to run.
Stop(); Stop();
} }
void CefProcessSubThread::Init() { void CefProcessSubThread::Init() {
#if defined(OS_WIN) #if defined(OS_WIN)
// Initializes the COM library on the current thread. // Initializes the COM library on the current thread.
CoInitialize(NULL); CoInitialize(NULL);
#endif #endif
} }
void CefProcessSubThread::CleanUp() { void CefProcessSubThread::CleanUp() {
// Flush any remaining messages. This ensures that any accumulated // Flush any remaining messages. This ensures that any accumulated
// Task objects get destroyed before we exit, which avoids noise in // Task objects get destroyed before we exit, which avoids noise in
// purify leak-test results. // purify leak-test results.
MessageLoop::current()->RunAllPending(); MessageLoop::current()->RunAllPending();
#if defined(OS_WIN) #if defined(OS_WIN)
// Closes the COM library on the current thread. CoInitialize must // Closes the COM library on the current thread. CoInitialize must
// be balanced by a corresponding call to CoUninitialize. // be balanced by a corresponding call to CoUninitialize.
CoUninitialize(); CoUninitialize();
#endif #endif
} }

View File

@ -1,178 +1,178 @@
// Copyright (c) 2010 The Chromium Embedded Framework Authors. // Copyright (c) 2010 The Chromium Embedded Framework Authors.
// Portions copyright (c) 2010 The Chromium Authors. All rights reserved. // Portions copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "cef_process_ui_thread.h" #include "cef_process_ui_thread.h"
#include "browser_impl.h" #include "browser_impl.h"
#include "browser_resource_loader_bridge.h" #include "browser_resource_loader_bridge.h"
#include "browser_request_context.h" #include "browser_request_context.h"
#include "browser_webkit_glue.h" #include "browser_webkit_glue.h"
#include "browser_webkit_init.h" #include "browser_webkit_init.h"
#include "cef_context.h" #include "cef_context.h"
#include "base/command_line.h" #include "base/command_line.h"
#include "base/i18n/icu_util.h" #include "base/i18n/icu_util.h"
#include "base/rand_util.h" #include "base/rand_util.h"
#include "base/stats_table.h" #include "base/stats_table.h"
#include "base/string_number_conversions.h" #include "base/string_number_conversions.h"
#include "build/build_config.h" #include "build/build_config.h"
#include "app/gfx/gl/gl_implementation.h" #include "app/gfx/gl/gl_implementation.h"
#include "net/base/net_module.h" #include "net/base/net_module.h"
#if defined(OS_WIN) #if defined(OS_WIN)
#include "net/socket/ssl_client_socket_nss_factory.h" #include "net/socket/ssl_client_socket_nss_factory.h"
#endif #endif
#include "webkit/blob/blob_storage_controller.h" #include "webkit/blob/blob_storage_controller.h"
#include "webkit/blob/blob_url_request_job.h" #include "webkit/blob/blob_url_request_job.h"
#include "webkit/extensions/v8/gc_extension.h" #include "webkit/extensions/v8/gc_extension.h"
#include "net/url_request/url_request.h" #include "net/url_request/url_request.h"
#if defined(OS_WIN) #if defined(OS_WIN)
#include <commctrl.h> #include <commctrl.h>
#include <Objbase.h> #include <Objbase.h>
#endif #endif
static const char* kStatsFilePrefix = "libcef_"; static const char* kStatsFilePrefix = "libcef_";
static int kStatsFileThreads = 20; static int kStatsFileThreads = 20;
static int kStatsFileCounters = 200; static int kStatsFileCounters = 200;
namespace { namespace {
URLRequestJob* BlobURLRequestJobFactory(URLRequest* request, URLRequestJob* BlobURLRequestJobFactory(URLRequest* request,
const std::string& scheme) { const std::string& scheme) {
webkit_blob::BlobStorageController* blob_storage_controller = webkit_blob::BlobStorageController* blob_storage_controller =
static_cast<BrowserRequestContext*>(request->context())-> static_cast<BrowserRequestContext*>(request->context())->
blob_storage_controller(); blob_storage_controller();
return new webkit_blob::BlobURLRequestJob( return new webkit_blob::BlobURLRequestJob(
request, request,
blob_storage_controller->GetBlobDataFromUrl(request->url()), blob_storage_controller->GetBlobDataFromUrl(request->url()),
NULL); NULL);
} }
} // namespace } // namespace
CefProcessUIThread::CefProcessUIThread() CefProcessUIThread::CefProcessUIThread()
: CefThread(CefThread::UI), statstable_(NULL), webkit_init_(NULL) {} : CefThread(CefThread::UI), statstable_(NULL), webkit_init_(NULL) {}
CefProcessUIThread::CefProcessUIThread(MessageLoop* message_loop) CefProcessUIThread::CefProcessUIThread(MessageLoop* message_loop)
: CefThread(CefThread::UI, message_loop), statstable_(NULL), : CefThread(CefThread::UI, message_loop), statstable_(NULL),
webkit_init_(NULL) {} webkit_init_(NULL) {}
CefProcessUIThread::~CefProcessUIThread() { CefProcessUIThread::~CefProcessUIThread() {
// We cannot rely on our base class to stop the thread since we want our // We cannot rely on our base class to stop the thread since we want our
// CleanUp function to run. // CleanUp function to run.
Stop(); Stop();
} }
void CefProcessUIThread::Init() { void CefProcessUIThread::Init() {
#if defined(OS_WIN) #if defined(OS_WIN)
HRESULT res; HRESULT res;
// Initialize common controls // Initialize common controls
res = CoInitialize(NULL); res = CoInitialize(NULL);
DCHECK(SUCCEEDED(res)); DCHECK(SUCCEEDED(res));
INITCOMMONCONTROLSEX InitCtrlEx; INITCOMMONCONTROLSEX InitCtrlEx;
InitCtrlEx.dwSize = sizeof(INITCOMMONCONTROLSEX); InitCtrlEx.dwSize = sizeof(INITCOMMONCONTROLSEX);
InitCtrlEx.dwICC = ICC_STANDARD_CLASSES; InitCtrlEx.dwICC = ICC_STANDARD_CLASSES;
InitCommonControlsEx(&InitCtrlEx); InitCommonControlsEx(&InitCtrlEx);
// Start COM stuff // Start COM stuff
res = OleInitialize(NULL); res = OleInitialize(NULL);
DCHECK(SUCCEEDED(res)); DCHECK(SUCCEEDED(res));
// Register the window class // Register the window class
WNDCLASSEX wcex = { WNDCLASSEX wcex = {
/* cbSize = */ sizeof(WNDCLASSEX), /* cbSize = */ sizeof(WNDCLASSEX),
/* style = */ CS_HREDRAW | CS_VREDRAW, /* style = */ CS_HREDRAW | CS_VREDRAW,
/* lpfnWndProc = */ CefBrowserImpl::WndProc, /* lpfnWndProc = */ CefBrowserImpl::WndProc,
/* cbClsExtra = */ 0, /* cbClsExtra = */ 0,
/* cbWndExtra = */ 0, /* cbWndExtra = */ 0,
/* hInstance = */ ::GetModuleHandle(NULL), /* hInstance = */ ::GetModuleHandle(NULL),
/* hIcon = */ NULL, /* hIcon = */ NULL,
/* hCursor = */ LoadCursor(NULL, IDC_ARROW), /* hCursor = */ LoadCursor(NULL, IDC_ARROW),
/* hbrBackground = */ 0, /* hbrBackground = */ 0,
/* lpszMenuName = */ NULL, /* lpszMenuName = */ NULL,
/* lpszClassName = */ CefBrowserImpl::GetWndClass(), /* lpszClassName = */ CefBrowserImpl::GetWndClass(),
/* hIconSm = */ NULL, /* hIconSm = */ NULL,
}; };
RegisterClassEx(&wcex); RegisterClassEx(&wcex);
#endif #endif
#ifndef _DEBUG #ifndef _DEBUG
// Only log error messages and above in release build. // Only log error messages and above in release build.
logging::SetMinLogLevel(logging::LOG_ERROR); logging::SetMinLogLevel(logging::LOG_ERROR);
#endif #endif
// Initialize the global CommandLine object. // Initialize the global CommandLine object.
CommandLine::Init(0, NULL); CommandLine::Init(0, NULL);
// Initialize WebKit. // Initialize WebKit.
webkit_init_ = new BrowserWebKitInit(); webkit_init_ = new BrowserWebKitInit();
// Initialize WebKit encodings // Initialize WebKit encodings
webkit_glue::InitializeTextEncoding(); webkit_glue::InitializeTextEncoding();
// Load ICU data tables. // Load ICU data tables.
bool ret = icu_util::Initialize(); bool ret = icu_util::Initialize();
if(!ret) { if(!ret) {
#if defined(OS_WIN) #if defined(OS_WIN)
MessageBox(NULL, L"Failed to load the required icudt38 library", MessageBox(NULL, L"Failed to load the required icudt38 library",
L"CEF Initialization Error", MB_ICONERROR | MB_OK); L"CEF Initialization Error", MB_ICONERROR | MB_OK);
#endif #endif
return; return;
} }
// Config the network module so it has access to a limited set of resources. // Config the network module so it has access to a limited set of resources.
net::NetModule::SetResourceProvider(webkit_glue::NetResourceProvider); net::NetModule::SetResourceProvider(webkit_glue::NetResourceProvider);
// Load and initialize the stats table. Attempt to construct a somewhat // Load and initialize the stats table. Attempt to construct a somewhat
// unique name to isolate separate instances from each other. // unique name to isolate separate instances from each other.
statstable_ = new StatsTable( statstable_ = new StatsTable(
kStatsFilePrefix + base::Uint64ToString(base::RandUint64()), kStatsFilePrefix + base::Uint64ToString(base::RandUint64()),
kStatsFileThreads, kStatsFileThreads,
kStatsFileCounters); kStatsFileCounters);
StatsTable::set_current(statstable_); StatsTable::set_current(statstable_);
// CEF always exposes the GC. // CEF always exposes the GC.
webkit_glue::SetJavaScriptFlags("--expose-gc"); webkit_glue::SetJavaScriptFlags("--expose-gc");
// Expose GCController to JavaScript. // Expose GCController to JavaScript.
WebKit::WebScriptController::registerExtension( WebKit::WebScriptController::registerExtension(
extensions_v8::GCExtension::Get()); extensions_v8::GCExtension::Get());
#if defined(OS_WIN) #if defined(OS_WIN)
// Use NSS for SSL on Windows. TODO(wtc): this should eventually be hidden // Use NSS for SSL on Windows. TODO(wtc): this should eventually be hidden
// inside DefaultClientSocketFactory::CreateSSLClientSocket. // inside DefaultClientSocketFactory::CreateSSLClientSocket.
net::ClientSocketFactory::SetSSLClientSocketFactory( net::ClientSocketFactory::SetSSLClientSocketFactory(
net::SSLClientSocketNSSFactory); net::SSLClientSocketNSSFactory);
#endif #endif
gfx::InitializeGLBindings(gfx::kGLImplementationOSMesaGL); gfx::InitializeGLBindings(gfx::kGLImplementationOSMesaGL);
URLRequest::RegisterProtocolFactory("blob", &BlobURLRequestJobFactory); URLRequest::RegisterProtocolFactory("blob", &BlobURLRequestJobFactory);
} }
void CefProcessUIThread::CleanUp() { void CefProcessUIThread::CleanUp() {
// Flush any remaining messages. This ensures that any accumulated // Flush any remaining messages. This ensures that any accumulated
// Task objects get destroyed before we exit, which avoids noise in // Task objects get destroyed before we exit, which avoids noise in
// purify leak-test results. // purify leak-test results.
MessageLoop::current()->RunAllPending(); MessageLoop::current()->RunAllPending();
// Tear down the shared StatsTable. // Tear down the shared StatsTable.
StatsTable::set_current(NULL); StatsTable::set_current(NULL);
delete statstable_; delete statstable_;
statstable_ = NULL; statstable_ = NULL;
// Shut down WebKit. // Shut down WebKit.
delete webkit_init_; delete webkit_init_;
webkit_init_ = NULL; webkit_init_ = NULL;
#if defined(OS_WIN) #if defined(OS_WIN)
// Uninitialize COM stuff // Uninitialize COM stuff
OleUninitialize(); OleUninitialize();
// Closes the COM library on the current thread. CoInitialize must // Closes the COM library on the current thread. CoInitialize must
// be balanced by a corresponding call to CoUninitialize. // be balanced by a corresponding call to CoUninitialize.
CoUninitialize(); CoUninitialize();
#endif #endif
} }

View File

@ -1,42 +1,42 @@
// Copyright (c) 2010 The Chromium Embedded Framework Authors. // Copyright (c) 2010 The Chromium Embedded Framework Authors.
// Portions copyright (c) 2010 The Chromium Authors. All rights reserved. // Portions copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef _CEF_PROCESS_UI_THREAD #ifndef _CEF_PROCESS_UI_THREAD
#define _CEF_PROCESS_UI_THREAD #define _CEF_PROCESS_UI_THREAD
#include "base/basictypes.h" #include "base/basictypes.h"
#include "cef_thread.h" #include "cef_thread.h"
class BrowserWebKitInit; class BrowserWebKitInit;
class StatsTable; class StatsTable;
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// CefProcessUIThread // CefProcessUIThread
// //
// This simple thread object is used for the specialized threads that the // This simple thread object is used for the specialized threads that the
// CefProcess spins up. // CefProcess spins up.
// //
// Applications must initialize the COM library before they can call // Applications must initialize the COM library before they can call
// COM library functions other than CoGetMalloc and memory allocation // COM library functions other than CoGetMalloc and memory allocation
// functions, so this class initializes COM for those users. // functions, so this class initializes COM for those users.
class CefProcessUIThread : public CefThread { class CefProcessUIThread : public CefThread {
public: public:
explicit CefProcessUIThread(); explicit CefProcessUIThread();
CefProcessUIThread(MessageLoop* message_loop); CefProcessUIThread(MessageLoop* message_loop);
virtual ~CefProcessUIThread(); virtual ~CefProcessUIThread();
virtual void Init(); virtual void Init();
virtual void CleanUp(); virtual void CleanUp();
private: private:
StatsTable* statstable_; StatsTable* statstable_;
// WebKit implementation class. // WebKit implementation class.
BrowserWebKitInit* webkit_init_; BrowserWebKitInit* webkit_init_;
DISALLOW_COPY_AND_ASSIGN(CefProcessUIThread); DISALLOW_COPY_AND_ASSIGN(CefProcessUIThread);
}; };
#endif // _CEF_PROCESS_UI_THREAD #endif // _CEF_PROCESS_UI_THREAD

View File

@ -1,163 +1,163 @@
// Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights // Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that // reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file. // can be found in the LICENSE file.
#include "include/cef_string.h" #include "include/cef_string.h"
#include <limits.h> #include <limits.h>
#include <malloc.h> #include <malloc.h>
#include <string.h> #include <string.h>
typedef unsigned long dword_t; typedef unsigned long dword_t;
CEF_EXPORT size_t cef_string_length(cef_string_t str) CEF_EXPORT size_t cef_string_length(cef_string_t str)
{ {
dword_t* ptr; dword_t* ptr;
if(!str) if(!str)
return 0; return 0;
// The string length, in bytes, is placed in a dword_t immediately proceeding // The string length, in bytes, is placed in a dword_t immediately proceeding
// the string value. // the string value.
ptr = (dword_t*)str; ptr = (dword_t*)str;
ptr--; ptr--;
return (size_t)(*ptr / sizeof(wchar_t)); return (size_t)(*ptr / sizeof(wchar_t));
} }
CEF_EXPORT cef_string_t cef_string_alloc(const wchar_t* str) CEF_EXPORT cef_string_t cef_string_alloc(const wchar_t* str)
{ {
if(!str) if(!str)
return NULL; return NULL;
return cef_string_alloc_length(str, wcslen(str)); return cef_string_alloc_length(str, wcslen(str));
} }
CEF_EXPORT cef_string_t cef_string_alloc_length(const wchar_t* str, CEF_EXPORT cef_string_t cef_string_alloc_length(const wchar_t* str,
size_t len) size_t len)
{ {
dword_t size, *ptr; dword_t size, *ptr;
wchar_t* newstr; wchar_t* newstr;
// Check that the size can fit in a dword_t. // Check that the size can fit in a dword_t.
if(len >= (UINT_MAX - sizeof(wchar_t) - sizeof(dword_t)) / sizeof(wchar_t)) if(len >= (UINT_MAX - sizeof(wchar_t) - sizeof(dword_t)) / sizeof(wchar_t))
return NULL; return NULL;
// Get the size of the string in bytes. // Get the size of the string in bytes.
size = sizeof(wchar_t) * len; size = sizeof(wchar_t) * len;
// Allocate the new buffer including space for the proceeding dword_t size // Allocate the new buffer including space for the proceeding dword_t size
// value and the terminating nul. // value and the terminating nul.
ptr = (dword_t*)malloc(sizeof(dword_t) + size + sizeof(wchar_t)); ptr = (dword_t*)malloc(sizeof(dword_t) + size + sizeof(wchar_t));
if(!ptr) if(!ptr)
return NULL; return NULL;
// Set the size as the first value in the newly allocated memory and // Set the size as the first value in the newly allocated memory and
// increment to the string location. // increment to the string location.
*ptr = size; *ptr = size;
ptr++; ptr++;
if(str != NULL) if(str != NULL)
{ {
// Copy the string to the buffer. // Copy the string to the buffer.
memcpy(ptr, str, size); memcpy(ptr, str, size);
} }
else else
{ {
// Initialize the string to zeros. // Initialize the string to zeros.
memset(ptr, 0, size); memset(ptr, 0, size);
} }
newstr = (wchar_t*)ptr; newstr = (wchar_t*)ptr;
// Nul-terminate the string. // Nul-terminate the string.
newstr[len] = '\0'; newstr[len] = '\0';
return (cef_string_t)newstr; return (cef_string_t)newstr;
} }
CEF_EXPORT int cef_string_realloc(cef_string_t* oldstr, const wchar_t* newstr) CEF_EXPORT int cef_string_realloc(cef_string_t* oldstr, const wchar_t* newstr)
{ {
if(!oldstr) if(!oldstr)
return 0; return 0;
// Free the old string. // Free the old string.
cef_string_free(*oldstr); cef_string_free(*oldstr);
// Copy the new string. // Copy the new string.
*oldstr = cef_string_alloc(newstr); *oldstr = cef_string_alloc(newstr);
return 1; return 1;
} }
CEF_EXPORT int cef_string_realloc_length(cef_string_t* oldstr, CEF_EXPORT int cef_string_realloc_length(cef_string_t* oldstr,
const wchar_t* newstr, const wchar_t* newstr,
size_t len) size_t len)
{ {
if(!oldstr) if(!oldstr)
return 0; return 0;
// Check that the size can fit in a dword_t. // Check that the size can fit in a dword_t.
if(len >= (UINT_MAX - sizeof(wchar_t) - sizeof(dword_t)) / sizeof(wchar_t)) if(len >= (UINT_MAX - sizeof(wchar_t) - sizeof(dword_t)) / sizeof(wchar_t))
return 0; return 0;
if(*oldstr) if(*oldstr)
{ {
dword_t newsize, *oldptr, *newptr; dword_t newsize, *oldptr, *newptr;
// Get the new size of the string in bytes. // Get the new size of the string in bytes.
newsize = sizeof(wchar_t) * len; newsize = sizeof(wchar_t) * len;
// Adjust the pointer to account for the dword_t immediately proceeding the // Adjust the pointer to account for the dword_t immediately proceeding the
// string value. // string value.
oldptr = (dword_t*)*oldstr; oldptr = (dword_t*)*oldstr;
oldptr--; oldptr--;
// Re-allocate the buffer including space for the proceeding dword_t size // Re-allocate the buffer including space for the proceeding dword_t size
// value and the terminating nul. // value and the terminating nul.
newptr = (dword_t*)realloc( newptr = (dword_t*)realloc(
oldptr, sizeof(dword_t) + newsize + sizeof(wchar_t)); oldptr, sizeof(dword_t) + newsize + sizeof(wchar_t));
if(!newptr) if(!newptr)
return 0; return 0;
// Set the size as the first value in the newly allocated memory and // Set the size as the first value in the newly allocated memory and
// increment to the string location. // increment to the string location.
*newptr = newsize; *newptr = newsize;
newptr++; newptr++;
// Set the string pointer to the beginning on the string in the newly // Set the string pointer to the beginning on the string in the newly
// allocated memory. // allocated memory.
*oldstr = (cef_string_t)newptr; *oldstr = (cef_string_t)newptr;
if(newstr) if(newstr)
{ {
// Copy the new string value. Use of memmove() ensures that any // Copy the new string value. Use of memmove() ensures that any
// overlapping region in the old string will be copied before being // overlapping region in the old string will be copied before being
// overwritten. // overwritten.
memmove(*oldstr, newstr, newsize); memmove(*oldstr, newstr, newsize);
// Nul-terminate the string. // Nul-terminate the string.
*oldstr[len] = '\0'; *oldstr[len] = '\0';
} }
} }
else else
{ {
// Allocate the string. // Allocate the string.
*oldstr = cef_string_alloc_length(newstr, len); *oldstr = cef_string_alloc_length(newstr, len);
} }
return 1; return 1;
} }
CEF_EXPORT void cef_string_free(cef_string_t str) CEF_EXPORT void cef_string_free(cef_string_t str)
{ {
dword_t* ptr; dword_t* ptr;
if(!str) if(!str)
return; return;
// The size is placed in a dword_t immediately proceeding the string value. // The size is placed in a dword_t immediately proceeding the string value.
ptr = (dword_t*)str; ptr = (dword_t*)str;
ptr--; ptr--;
free(ptr); free(ptr);
} }

View File

@ -1,55 +1,55 @@
// Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights // Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that // reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file. // can be found in the LICENSE file.
#include "include/cef_string_list.h" #include "include/cef_string_list.h"
#include "base/logging.h" #include "base/logging.h"
#include <vector> #include <vector>
typedef std::vector<std::wstring> StringList; typedef std::vector<std::wstring> StringList;
CEF_EXPORT cef_string_list_t cef_string_list_alloc() CEF_EXPORT cef_string_list_t cef_string_list_alloc()
{ {
return new StringList; return new StringList;
} }
CEF_EXPORT int cef_string_list_size(cef_string_list_t list) CEF_EXPORT int cef_string_list_size(cef_string_list_t list)
{ {
DCHECK(list); DCHECK(list);
StringList* impl = (StringList*)list; StringList* impl = (StringList*)list;
return impl->size(); return impl->size();
} }
CEF_EXPORT cef_string_t cef_string_list_value(cef_string_list_t list, int index) CEF_EXPORT cef_string_t cef_string_list_value(cef_string_list_t list, int index)
{ {
DCHECK(list); DCHECK(list);
StringList* impl = (StringList*)list; StringList* impl = (StringList*)list;
DCHECK(index >= 0 && index < (int)impl->size()); DCHECK(index >= 0 && index < (int)impl->size());
if(index < 0 || index >= (int)impl->size()) if(index < 0 || index >= (int)impl->size())
return NULL; return NULL;
return cef_string_alloc((*impl)[index].c_str()); return cef_string_alloc((*impl)[index].c_str());
} }
CEF_EXPORT void cef_string_list_append(cef_string_list_t list, const wchar_t* value) CEF_EXPORT void cef_string_list_append(cef_string_list_t list, const wchar_t* value)
{ {
DCHECK(list); DCHECK(list);
StringList* impl = (StringList*)list; StringList* impl = (StringList*)list;
std::wstring valstr; std::wstring valstr;
if(value) if(value)
valstr = value; valstr = value;
impl->push_back(valstr); impl->push_back(valstr);
} }
CEF_EXPORT void cef_string_list_clear(cef_string_list_t list) CEF_EXPORT void cef_string_list_clear(cef_string_list_t list)
{ {
DCHECK(list); DCHECK(list);
StringList* impl = (StringList*)list; StringList* impl = (StringList*)list;
impl->clear(); impl->clear();
} }
CEF_EXPORT void cef_string_list_free(cef_string_list_t list) CEF_EXPORT void cef_string_list_free(cef_string_list_t list)
{ {
DCHECK(list); DCHECK(list);
delete (StringList*)list; delete (StringList*)list;
} }

View File

@ -1,92 +1,92 @@
// Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights // Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that // reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file. // can be found in the LICENSE file.
#include "include/cef_string_map.h" #include "include/cef_string_map.h"
#include "base/logging.h" #include "base/logging.h"
#include <map> #include <map>
typedef std::map<std::wstring, std::wstring> StringMap; typedef std::map<std::wstring, std::wstring> StringMap;
CEF_EXPORT cef_string_map_t cef_string_map_alloc() CEF_EXPORT cef_string_map_t cef_string_map_alloc()
{ {
return new StringMap; return new StringMap;
} }
CEF_EXPORT int cef_string_map_size(cef_string_map_t map) CEF_EXPORT int cef_string_map_size(cef_string_map_t map)
{ {
DCHECK(map); DCHECK(map);
StringMap* impl = (StringMap*)map; StringMap* impl = (StringMap*)map;
return impl->size(); return impl->size();
} }
CEF_EXPORT cef_string_t cef_string_map_find(cef_string_map_t map, CEF_EXPORT cef_string_t cef_string_map_find(cef_string_map_t map,
const wchar_t* key) const wchar_t* key)
{ {
DCHECK(map); DCHECK(map);
StringMap* impl = (StringMap*)map; StringMap* impl = (StringMap*)map;
std::wstring keystr; std::wstring keystr;
if(key) if(key)
keystr = key; keystr = key;
StringMap::const_iterator it = impl->find(keystr); StringMap::const_iterator it = impl->find(keystr);
if(it == impl->end()) if(it == impl->end())
return NULL; return NULL;
return cef_string_alloc(it->second.c_str()); return cef_string_alloc(it->second.c_str());
} }
CEF_EXPORT cef_string_t cef_string_map_key(cef_string_map_t map, int index) CEF_EXPORT cef_string_t cef_string_map_key(cef_string_map_t map, int index)
{ {
DCHECK(map); DCHECK(map);
StringMap* impl = (StringMap*)map; StringMap* impl = (StringMap*)map;
DCHECK(index >= 0 && index < (int)impl->size()); DCHECK(index >= 0 && index < (int)impl->size());
if(index < 0 || index >= (int)impl->size()) if(index < 0 || index >= (int)impl->size())
return NULL; return NULL;
StringMap::const_iterator it = impl->begin(); StringMap::const_iterator it = impl->begin();
for(int ct = 0; it != impl->end(); ++it, ct++) { for(int ct = 0; it != impl->end(); ++it, ct++) {
if(ct == index) if(ct == index)
return cef_string_alloc(it->first.c_str()); return cef_string_alloc(it->first.c_str());
} }
return NULL; return NULL;
} }
CEF_EXPORT cef_string_t cef_string_map_value(cef_string_map_t map, int index) CEF_EXPORT cef_string_t cef_string_map_value(cef_string_map_t map, int index)
{ {
DCHECK(map); DCHECK(map);
StringMap* impl = (StringMap*)map; StringMap* impl = (StringMap*)map;
DCHECK(index >= 0 && index < (int)impl->size()); DCHECK(index >= 0 && index < (int)impl->size());
if(index < 0 || index >= (int)impl->size()) if(index < 0 || index >= (int)impl->size())
return NULL; return NULL;
StringMap::const_iterator it = impl->begin(); StringMap::const_iterator it = impl->begin();
for(int ct = 0; it != impl->end(); ++it, ct++) { for(int ct = 0; it != impl->end(); ++it, ct++) {
if(ct == index) if(ct == index)
return cef_string_alloc(it->second.c_str()); return cef_string_alloc(it->second.c_str());
} }
return NULL; return NULL;
} }
CEF_EXPORT void cef_string_map_append(cef_string_map_t map, const wchar_t* key, CEF_EXPORT void cef_string_map_append(cef_string_map_t map, const wchar_t* key,
const wchar_t* value) const wchar_t* value)
{ {
DCHECK(map); DCHECK(map);
StringMap* impl = (StringMap*)map; StringMap* impl = (StringMap*)map;
std::wstring keystr, valstr; std::wstring keystr, valstr;
if(key) if(key)
keystr = key; keystr = key;
if(value) if(value)
valstr = value; valstr = value;
impl->insert(std::pair<std::wstring, std::wstring>(keystr, valstr)); impl->insert(std::pair<std::wstring, std::wstring>(keystr, valstr));
} }
CEF_EXPORT void cef_string_map_clear(cef_string_map_t map) CEF_EXPORT void cef_string_map_clear(cef_string_map_t map)
{ {
DCHECK(map); DCHECK(map);
StringMap* impl = (StringMap*)map; StringMap* impl = (StringMap*)map;
impl->clear(); impl->clear();
} }
CEF_EXPORT void cef_string_map_free(cef_string_map_t map) CEF_EXPORT void cef_string_map_free(cef_string_map_t map)
{ {
DCHECK(map); DCHECK(map);
delete (StringMap*)map; delete (StringMap*)map;
} }

View File

@ -1,185 +1,185 @@
// Copyright (c) 2010 The Chromium Embedded Framework Authors. // Copyright (c) 2010 The Chromium Embedded Framework Authors.
// Portions copyright (c) 2010 The Chromium Authors. All rights reserved. // Portions copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef _CEF_THREAD_H #ifndef _CEF_THREAD_H
#define _CEF_THREAD_H #define _CEF_THREAD_H
#include "base/lock.h" #include "base/lock.h"
#include "base/task.h" #include "base/task.h"
#include "base/thread.h" #include "base/thread.h"
namespace base { namespace base {
class MessageLoopProxy; class MessageLoopProxy;
} }
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// CefThread // CefThread
// //
// This class represents a thread that is known by a browser-wide name. For // This class represents a thread that is known by a browser-wide name. For
// example, there is one IO thread for the entire browser process, and various // example, there is one IO thread for the entire browser process, and various
// pieces of code find it useful to retrieve a pointer to the IO thread's // pieces of code find it useful to retrieve a pointer to the IO thread's
// Invoke a task by thread ID: // Invoke a task by thread ID:
// //
// CefThread::PostTask(CefThread::IO, FROM_HERE, task); // CefThread::PostTask(CefThread::IO, FROM_HERE, task);
// //
// The return value is false if the task couldn't be posted because the target // The return value is false if the task couldn't be posted because the target
// thread doesn't exist. If this could lead to data loss, you need to check the // thread doesn't exist. If this could lead to data loss, you need to check the
// result and restructure the code to ensure it doesn't occur. // result and restructure the code to ensure it doesn't occur.
// //
// This class automatically handles the lifetime of different threads. // This class automatically handles the lifetime of different threads.
// It's always safe to call PostTask on any thread. If it's not yet created, // It's always safe to call PostTask on any thread. If it's not yet created,
// the task is deleted. There are no race conditions. If the thread that the // the task is deleted. There are no race conditions. If the thread that the
// task is posted to is guaranteed to outlive the current thread, then no locks // task is posted to is guaranteed to outlive the current thread, then no locks
// are used. You should never need to cache pointers to MessageLoops, since // are used. You should never need to cache pointers to MessageLoops, since
// they're not thread safe. // they're not thread safe.
class CefThread : public base::Thread { class CefThread : public base::Thread {
public: public:
// An enumeration of the well-known threads. // An enumeration of the well-known threads.
// NOTE: threads must be listed in the order of their life-time, with each // NOTE: threads must be listed in the order of their life-time, with each
// thread outliving every other thread below it. // thread outliving every other thread below it.
enum ID { enum ID {
// The main thread in the browser. // The main thread in the browser.
UI, UI,
// This is the thread that interacts with the file system. // This is the thread that interacts with the file system.
FILE, FILE,
// This is the thread that processes network and schema messages. // This is the thread that processes network and schema messages.
IO, IO,
// This identifier does not represent a thread. Instead it counts the // This identifier does not represent a thread. Instead it counts the
// number of well-known threads. Insert new well-known threads before this // number of well-known threads. Insert new well-known threads before this
// identifier. // identifier.
ID_COUNT ID_COUNT
}; };
// Construct a CefThread with the supplied identifier. It is an error // Construct a CefThread with the supplied identifier. It is an error
// to construct a CefThread that already exists. // to construct a CefThread that already exists.
explicit CefThread(ID identifier); explicit CefThread(ID identifier);
// Special constructor for the main (UI) thread and unittests. We use a dummy // Special constructor for the main (UI) thread and unittests. We use a dummy
// thread here since the main thread already exists. // thread here since the main thread already exists.
CefThread(ID identifier, MessageLoop* message_loop); CefThread(ID identifier, MessageLoop* message_loop);
virtual ~CefThread(); virtual ~CefThread();
// These are the same methods in message_loop.h, but are guaranteed to either // These are the same methods in message_loop.h, but are guaranteed to either
// get posted to the MessageLoop if it's still alive, or be deleted otherwise. // get posted to the MessageLoop if it's still alive, or be deleted otherwise.
// They return true if the thread existed and the task was posted. Note that // They return true if the thread existed and the task was posted. Note that
// even if the task is posted, there's no guarantee that it will run, since // even if the task is posted, there's no guarantee that it will run, since
// the target thread may already have a Quit message in its queue. // the target thread may already have a Quit message in its queue.
static bool PostTask(ID identifier, static bool PostTask(ID identifier,
const tracked_objects::Location& from_here, const tracked_objects::Location& from_here,
Task* task); Task* task);
static bool PostDelayedTask(ID identifier, static bool PostDelayedTask(ID identifier,
const tracked_objects::Location& from_here, const tracked_objects::Location& from_here,
Task* task, Task* task,
int64 delay_ms); int64 delay_ms);
static bool PostNonNestableTask(ID identifier, static bool PostNonNestableTask(ID identifier,
const tracked_objects::Location& from_here, const tracked_objects::Location& from_here,
Task* task); Task* task);
static bool PostNonNestableDelayedTask( static bool PostNonNestableDelayedTask(
ID identifier, ID identifier,
const tracked_objects::Location& from_here, const tracked_objects::Location& from_here,
Task* task, Task* task,
int64 delay_ms); int64 delay_ms);
template <class T> template <class T>
static bool DeleteSoon(ID identifier, static bool DeleteSoon(ID identifier,
const tracked_objects::Location& from_here, const tracked_objects::Location& from_here,
T* object) { T* object) {
return PostNonNestableTask( return PostNonNestableTask(
identifier, from_here, new DeleteTask<T>(object)); identifier, from_here, new DeleteTask<T>(object));
} }
template <class T> template <class T>
static bool ReleaseSoon(ID identifier, static bool ReleaseSoon(ID identifier,
const tracked_objects::Location& from_here, const tracked_objects::Location& from_here,
T* object) { T* object) {
return PostNonNestableTask( return PostNonNestableTask(
identifier, from_here, new ReleaseTask<T>(object)); identifier, from_here, new ReleaseTask<T>(object));
} }
// Callable on any thread. Returns whether the given ID corresponds to a well // Callable on any thread. Returns whether the given ID corresponds to a well
// known thread. // known thread.
static bool IsWellKnownThread(ID identifier); static bool IsWellKnownThread(ID identifier);
// Callable on any thread. Returns whether you're currently on a particular // Callable on any thread. Returns whether you're currently on a particular
// thread. // thread.
static bool CurrentlyOn(ID identifier); static bool CurrentlyOn(ID identifier);
// If the current message loop is one of the known threads, returns true and // If the current message loop is one of the known threads, returns true and
// sets identifier to its ID. Otherwise returns false. // sets identifier to its ID. Otherwise returns false.
static bool GetCurrentThreadIdentifier(ID* identifier); static bool GetCurrentThreadIdentifier(ID* identifier);
// Callers can hold on to a refcounted MessageLoopProxy beyond the lifetime // Callers can hold on to a refcounted MessageLoopProxy beyond the lifetime
// of the thread. // of the thread.
static scoped_refptr<base::MessageLoopProxy> GetMessageLoopProxyForThread( static scoped_refptr<base::MessageLoopProxy> GetMessageLoopProxyForThread(
ID identifier); ID identifier);
// Use these templates in conjuction with RefCountedThreadSafe when you want // Use these templates in conjuction with RefCountedThreadSafe when you want
// to ensure that an object is deleted on a specific thread. This is needed // to ensure that an object is deleted on a specific thread. This is needed
// when an object can hop between threads (i.e. IO -> FILE -> IO), and thread // when an object can hop between threads (i.e. IO -> FILE -> IO), and thread
// switching delays can mean that the final IO tasks executes before the FILE // switching delays can mean that the final IO tasks executes before the FILE
// task's stack unwinds. This would lead to the object destructing on the // task's stack unwinds. This would lead to the object destructing on the
// FILE thread, which often is not what you want (i.e. to unregister from // FILE thread, which often is not what you want (i.e. to unregister from
// NotificationService, to notify other objects on the creating thread etc). // NotificationService, to notify other objects on the creating thread etc).
template<ID thread> template<ID thread>
struct DeleteOnThread { struct DeleteOnThread {
template<typename T> template<typename T>
static void Destruct(T* x) { static void Destruct(T* x) {
if (CurrentlyOn(thread)) { if (CurrentlyOn(thread)) {
delete x; delete x;
} else { } else {
DeleteSoon(thread, FROM_HERE, x); DeleteSoon(thread, FROM_HERE, x);
} }
} }
}; };
// Sample usage: // Sample usage:
// class Foo // class Foo
// : public base::RefCountedThreadSafe< // : public base::RefCountedThreadSafe<
// Foo, CefThread::DeleteOnIOThread> { // Foo, CefThread::DeleteOnIOThread> {
// //
// ... // ...
// private: // private:
// friend class CefThread; // friend class CefThread;
// friend class DeleteTask<Foo>; // friend class DeleteTask<Foo>;
// //
// ~Foo(); // ~Foo();
struct DeleteOnUIThread : public DeleteOnThread<UI> { }; struct DeleteOnUIThread : public DeleteOnThread<UI> { };
struct DeleteOnIOThread : public DeleteOnThread<IO> { }; struct DeleteOnIOThread : public DeleteOnThread<IO> { };
struct DeleteOnFileThread : public DeleteOnThread<FILE> { }; struct DeleteOnFileThread : public DeleteOnThread<FILE> { };
private: private:
// Common initialization code for the constructors. // Common initialization code for the constructors.
void Initialize(); void Initialize();
static bool PostTaskHelper( static bool PostTaskHelper(
ID identifier, ID identifier,
const tracked_objects::Location& from_here, const tracked_objects::Location& from_here,
Task* task, Task* task,
int64 delay_ms, int64 delay_ms,
bool nestable); bool nestable);
// The identifier of this thread. Only one thread can exist with a given // The identifier of this thread. Only one thread can exist with a given
// identifier at a given time. // identifier at a given time.
ID identifier_; ID identifier_;
// This lock protects |cef_threads_|. Do not read or modify that array // This lock protects |cef_threads_|. Do not read or modify that array
// without holding this lock. Do not block while holding this lock. // without holding this lock. Do not block while holding this lock.
static Lock lock_; static Lock lock_;
// An array of the CefThread objects. This array is protected by |lock_|. // An array of the CefThread objects. This array is protected by |lock_|.
// The threads are not owned by this array. Typically, the threads are owned // The threads are not owned by this array. Typically, the threads are owned
// on the UI thread by the g_browser_process object. CefThreads remove // on the UI thread by the g_browser_process object. CefThreads remove
// themselves from this array upon destruction. // themselves from this array upon destruction.
static CefThread* cef_threads_[ID_COUNT]; static CefThread* cef_threads_[ID_COUNT];
}; };
#define REQUIRE_UIT() DCHECK(CefThread::CurrentlyOn(CefThread::UI)) #define REQUIRE_UIT() DCHECK(CefThread::CurrentlyOn(CefThread::UI))
#define REQUIRE_IOT() DCHECK(CefThread::CurrentlyOn(CefThread::IO)) #define REQUIRE_IOT() DCHECK(CefThread::CurrentlyOn(CefThread::IO))
#endif // _CEF_THREAD_H #endif // _CEF_THREAD_H

View File

@ -1,265 +1,265 @@
// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "print_settings.h" #include "print_settings.h"
#include "base/atomic_sequence_num.h" #include "base/atomic_sequence_num.h"
#include "base/logging.h" #include "base/logging.h"
#include "printing/units.h" #include "printing/units.h"
namespace printing { namespace printing {
// Global SequenceNumber used for generating unique cookie values. // Global SequenceNumber used for generating unique cookie values.
static base::AtomicSequenceNumber cookie_seq(base::LINKER_INITIALIZED); static base::AtomicSequenceNumber cookie_seq(base::LINKER_INITIALIZED);
PageMeasurements::PageMeasurements() PageMeasurements::PageMeasurements()
: page_type(PT_LETTER), : page_type(PT_LETTER),
page_length(0.0f), page_length(0.0f),
page_width(0.0f) { page_width(0.0f) {
} }
void PageMeasurements::Clear() { void PageMeasurements::Clear() {
page_type = PT_LETTER; page_type = PT_LETTER;
page_length = 0.0f; page_length = 0.0f;
page_width = 0.0f; page_width = 0.0f;
} }
bool PageMeasurements::Equals(const PageMeasurements& rhs) const { bool PageMeasurements::Equals(const PageMeasurements& rhs) const {
return page_type == rhs.page_type && return page_type == rhs.page_type &&
page_length == rhs.page_length && page_length == rhs.page_length &&
page_width == rhs.page_width; page_width == rhs.page_width;
} }
PrintSettings::PrintSettings() PrintSettings::PrintSettings()
: min_shrink(1.25), : min_shrink(1.25),
max_shrink(2.0), max_shrink(2.0),
desired_dpi(72), desired_dpi(72),
selection_only(false), selection_only(false),
to_file(false), to_file(false),
dpi_(0), dpi_(0),
landscape(false) { landscape(false) {
ResetRequestedPageMargins(); ResetRequestedPageMargins();
} }
void PrintSettings::Clear() { void PrintSettings::Clear() {
ranges.clear(); ranges.clear();
min_shrink = 1.25; min_shrink = 1.25;
max_shrink = 2.; max_shrink = 2.;
desired_dpi = 72; desired_dpi = 72;
selection_only = false; selection_only = false;
to_file = false; to_file = false;
printer_name_.clear(); printer_name_.clear();
device_name_.clear(); device_name_.clear();
page_setup_pixels_.Clear(); page_setup_pixels_.Clear();
dpi_ = 0; dpi_ = 0;
landscape = false; landscape = false;
page_measurements.Clear(); page_measurements.Clear();
ResetRequestedPageMargins(); ResetRequestedPageMargins();
} }
void PrintSettings::ResetRequestedPageMargins() { void PrintSettings::ResetRequestedPageMargins() {
// Initial requested margins to = 1.0cm = ~2/5 of inch // Initial requested margins to = 1.0cm = ~2/5 of inch
const int margin_printer_units = ConvertUnit(1000, kHundrethsMMPerInch, desired_dpi); const int margin_printer_units = ConvertUnit(1000, kHundrethsMMPerInch, desired_dpi);
// Initial requested header/footer margins to = 0.5cm = ~1/5 of inch // Initial requested header/footer margins to = 0.5cm = ~1/5 of inch
const int header_footer_margins = ConvertUnit(500, kHundrethsMMPerInch, desired_dpi); const int header_footer_margins = ConvertUnit(500, kHundrethsMMPerInch, desired_dpi);
requested_margins.header = header_footer_margins; requested_margins.header = header_footer_margins;
requested_margins.footer = header_footer_margins; requested_margins.footer = header_footer_margins;
requested_margins.left = margin_printer_units; requested_margins.left = margin_printer_units;
requested_margins.top = margin_printer_units; requested_margins.top = margin_printer_units;
requested_margins.right = margin_printer_units; requested_margins.right = margin_printer_units;
requested_margins.bottom = margin_printer_units; requested_margins.bottom = margin_printer_units;
} }
#ifdef WIN32 #ifdef WIN32
void PrintSettings::Init(HDC hdc, void PrintSettings::Init(HDC hdc,
const DEVMODE& dev_mode, const DEVMODE& dev_mode,
const PageRanges& new_ranges, const PageRanges& new_ranges,
const std::wstring& new_device_name, const std::wstring& new_device_name,
bool print_selection_only, bool print_selection_only,
bool print_to_file) { bool print_to_file) {
DCHECK(hdc); DCHECK(hdc);
printer_name_ = dev_mode.dmDeviceName; printer_name_ = dev_mode.dmDeviceName;
device_name_ = new_device_name; device_name_ = new_device_name;
ranges = new_ranges; ranges = new_ranges;
landscape = dev_mode.dmOrientation == DMORIENT_LANDSCAPE; landscape = dev_mode.dmOrientation == DMORIENT_LANDSCAPE;
selection_only = print_selection_only; selection_only = print_selection_only;
to_file = print_to_file; to_file = print_to_file;
bool is_custom_paper = true; bool is_custom_paper = true;
if (dev_mode.dmFields & DM_PAPERSIZE) { if (dev_mode.dmFields & DM_PAPERSIZE) {
switch(dev_mode.dmPaperSize) { switch(dev_mode.dmPaperSize) {
case DMPAPER_LETTER: case DMPAPER_LETTER:
page_measurements.page_type = PT_LETTER; page_measurements.page_type = PT_LETTER;
is_custom_paper = false; is_custom_paper = false;
break; break;
case DMPAPER_LEGAL: case DMPAPER_LEGAL:
page_measurements.page_type = PT_LEGAL; page_measurements.page_type = PT_LEGAL;
is_custom_paper = false; is_custom_paper = false;
break; break;
case DMPAPER_EXECUTIVE: case DMPAPER_EXECUTIVE:
page_measurements.page_type = PT_EXECUTIVE; page_measurements.page_type = PT_EXECUTIVE;
is_custom_paper = false; is_custom_paper = false;
break; break;
case DMPAPER_A3: case DMPAPER_A3:
page_measurements.page_type = PT_A3; page_measurements.page_type = PT_A3;
is_custom_paper = false; is_custom_paper = false;
break; break;
case DMPAPER_A4: case DMPAPER_A4:
page_measurements.page_type = PT_A4; page_measurements.page_type = PT_A4;
is_custom_paper = false; is_custom_paper = false;
break; break;
default: default:
//we'll translate it as a custom paper size. //we'll translate it as a custom paper size.
break; break;
} }
} }
dpi_ = GetDeviceCaps(hdc, LOGPIXELSX); dpi_ = GetDeviceCaps(hdc, LOGPIXELSX);
// No printer device is known to advertise different dpi in X and Y axis; even // No printer device is known to advertise different dpi in X and Y axis; even
// the fax device using the 200x100 dpi setting. It's ought to break so many // the fax device using the 200x100 dpi setting. It's ought to break so many
// applications that it's not even needed to care about. WebKit doesn't // applications that it's not even needed to care about. WebKit doesn't
// support different dpi settings in X and Y axis. // support different dpi settings in X and Y axis.
DCHECK_EQ(dpi_, GetDeviceCaps(hdc, LOGPIXELSY)); DCHECK_EQ(dpi_, GetDeviceCaps(hdc, LOGPIXELSY));
DCHECK_EQ(GetDeviceCaps(hdc, SCALINGFACTORX), 0); DCHECK_EQ(GetDeviceCaps(hdc, SCALINGFACTORX), 0);
DCHECK_EQ(GetDeviceCaps(hdc, SCALINGFACTORY), 0); DCHECK_EQ(GetDeviceCaps(hdc, SCALINGFACTORY), 0);
// Initialize page_setup_pixels_. // Initialize page_setup_pixels_.
gfx::Size physical_size_pixels(GetDeviceCaps(hdc, PHYSICALWIDTH), gfx::Size physical_size_pixels(GetDeviceCaps(hdc, PHYSICALWIDTH),
GetDeviceCaps(hdc, PHYSICALHEIGHT)); GetDeviceCaps(hdc, PHYSICALHEIGHT));
gfx::Rect printable_area_pixels(GetDeviceCaps(hdc, PHYSICALOFFSETX), gfx::Rect printable_area_pixels(GetDeviceCaps(hdc, PHYSICALOFFSETX),
GetDeviceCaps(hdc, PHYSICALOFFSETY), GetDeviceCaps(hdc, PHYSICALOFFSETY),
GetDeviceCaps(hdc, HORZRES), GetDeviceCaps(hdc, HORZRES),
GetDeviceCaps(hdc, VERTRES)); GetDeviceCaps(hdc, VERTRES));
if (is_custom_paper) { if (is_custom_paper) {
page_measurements.page_length = ConvertUnitDouble( page_measurements.page_length = ConvertUnitDouble(
static_cast<double>(physical_size_pixels.height()), static_cast<double>(physical_size_pixels.height()),
static_cast<double>(dpi_), static_cast<double>(dpi_),
static_cast<double>(desired_dpi)); static_cast<double>(desired_dpi));
page_measurements.page_width = ConvertUnitDouble( page_measurements.page_width = ConvertUnitDouble(
static_cast<double>(physical_size_pixels.width()), static_cast<double>(physical_size_pixels.width()),
static_cast<double>(dpi_), static_cast<double>(dpi_),
static_cast<double>(desired_dpi)); static_cast<double>(desired_dpi));
if (landscape) { if (landscape) {
double temp = page_measurements.page_length; double temp = page_measurements.page_length;
page_measurements.page_length = page_measurements.page_width; page_measurements.page_length = page_measurements.page_width;
page_measurements.page_width = temp; page_measurements.page_width = temp;
} }
} }
SetPrinterPrintableArea(physical_size_pixels, printable_area_pixels); SetPrinterPrintableArea(physical_size_pixels, printable_area_pixels);
} }
#endif #endif
void PrintSettings::SetPrinterPrintableArea( void PrintSettings::SetPrinterPrintableArea(
gfx::Size const& physical_size_pixels, gfx::Size const& physical_size_pixels,
gfx::Rect const& printable_area_pixels) { gfx::Rect const& printable_area_pixels) {
// Hard-code text_height = 0.5cm = ~1/5 of inch // Hard-code text_height = 0.5cm = ~1/5 of inch
const int text_height = ConvertUnit(500, kHundrethsMMPerInch, dpi_); const int text_height = ConvertUnit(500, kHundrethsMMPerInch, dpi_);
// Start by setting the user configuration // Start by setting the user configuration
page_setup_pixels_.Init(physical_size_pixels, page_setup_pixels_.Init(physical_size_pixels,
printable_area_pixels, printable_area_pixels,
text_height); text_height);
// Now adjust requested margins to the appropriate dpi. // Now adjust requested margins to the appropriate dpi.
PageMargins margins; PageMargins margins;
margins.header = ConvertUnit(requested_margins.header, desired_dpi, dpi_); margins.header = ConvertUnit(requested_margins.header, desired_dpi, dpi_);
margins.footer = ConvertUnit(requested_margins.footer, desired_dpi, dpi_); margins.footer = ConvertUnit(requested_margins.footer, desired_dpi, dpi_);
margins.left = ConvertUnit(requested_margins.left, desired_dpi, dpi_); margins.left = ConvertUnit(requested_margins.left, desired_dpi, dpi_);
margins.top = ConvertUnit(requested_margins.top, desired_dpi, dpi_); margins.top = ConvertUnit(requested_margins.top, desired_dpi, dpi_);
margins.right = ConvertUnit(requested_margins.right, desired_dpi, dpi_); margins.right = ConvertUnit(requested_margins.right, desired_dpi, dpi_);
margins.bottom = ConvertUnit(requested_margins.bottom, desired_dpi, dpi_); margins.bottom = ConvertUnit(requested_margins.bottom, desired_dpi, dpi_);
page_setup_pixels_.SetRequestedMargins(margins); page_setup_pixels_.SetRequestedMargins(margins);
} }
void PrintSettings::RenderParams(PrintParams* params) const { void PrintSettings::RenderParams(PrintParams* params) const {
DCHECK(params); DCHECK(params);
params->printable_size.SetSize(page_setup_pixels_.content_area().width(), params->printable_size.SetSize(page_setup_pixels_.content_area().width(),
page_setup_pixels_.content_area().height()); page_setup_pixels_.content_area().height());
params->dpi = dpi_; params->dpi = dpi_;
// Currently hardcoded at 1.25. See PrintSettings' constructor. // Currently hardcoded at 1.25. See PrintSettings' constructor.
params->min_shrink = min_shrink; params->min_shrink = min_shrink;
// Currently hardcoded at 2.0. See PrintSettings' constructor. // Currently hardcoded at 2.0. See PrintSettings' constructor.
params->max_shrink = max_shrink; params->max_shrink = max_shrink;
// Currently hardcoded at 72dpi. See PrintSettings' constructor. // Currently hardcoded at 72dpi. See PrintSettings' constructor.
params->desired_dpi = desired_dpi; params->desired_dpi = desired_dpi;
// Always use an invalid cookie. // Always use an invalid cookie.
params->document_cookie = 0; params->document_cookie = 0;
params->selection_only = selection_only; params->selection_only = selection_only;
params->to_file = to_file; params->to_file = to_file;
} }
bool PrintSettings::Equals(const PrintSettings& rhs) const { bool PrintSettings::Equals(const PrintSettings& rhs) const {
// Do not test the display device name (printer_name_) for equality since it // Do not test the display device name (printer_name_) for equality since it
// may sometimes be chopped off at 30 chars. As long as device_name is the // may sometimes be chopped off at 30 chars. As long as device_name is the
// same, that's fine. // same, that's fine.
return ranges == rhs.ranges && return ranges == rhs.ranges &&
min_shrink == rhs.min_shrink && min_shrink == rhs.min_shrink &&
max_shrink == rhs.max_shrink && max_shrink == rhs.max_shrink &&
desired_dpi == rhs.desired_dpi && desired_dpi == rhs.desired_dpi &&
device_name_ == rhs.device_name_ && device_name_ == rhs.device_name_ &&
page_setup_pixels_.Equals(rhs.page_setup_pixels_) && page_setup_pixels_.Equals(rhs.page_setup_pixels_) &&
dpi_ == rhs.dpi_ && dpi_ == rhs.dpi_ &&
landscape == rhs.landscape && landscape == rhs.landscape &&
page_measurements.Equals(rhs.page_measurements) && page_measurements.Equals(rhs.page_measurements) &&
requested_margins.Equals(rhs.requested_margins); requested_margins.Equals(rhs.requested_margins);
} }
int PrintSettings::NewCookie() { int PrintSettings::NewCookie() {
// A cookie of 0 is used to mark a document as unassigned, count from 1. // A cookie of 0 is used to mark a document as unassigned, count from 1.
return cookie_seq.GetNext() + 1; return cookie_seq.GetNext() + 1;
} }
void PrintSettings::UpdatePrintOptions(cef_print_options_t& print_options) { void PrintSettings::UpdatePrintOptions(cef_print_options_t& print_options) {
print_options.page_orientation = (landscape) ? LANDSCAPE : PORTRAIT; print_options.page_orientation = (landscape) ? LANDSCAPE : PORTRAIT;
print_options.paper_metrics.paper_type = page_measurements.page_type; print_options.paper_metrics.paper_type = page_measurements.page_type;
if (page_measurements.page_type == PT_CUSTOM) { if (page_measurements.page_type == PT_CUSTOM) {
print_options.paper_metrics.length = ConvertUnitDouble( print_options.paper_metrics.length = ConvertUnitDouble(
page_measurements.page_length, desired_dpi, 1); page_measurements.page_length, desired_dpi, 1);
print_options.paper_metrics.width = ConvertUnitDouble( print_options.paper_metrics.width = ConvertUnitDouble(
page_measurements.page_width, desired_dpi, 1); page_measurements.page_width, desired_dpi, 1);
} }
print_options.paper_margins.left = ConvertUnitDouble( print_options.paper_margins.left = ConvertUnitDouble(
requested_margins.left, desired_dpi, 1); requested_margins.left, desired_dpi, 1);
print_options.paper_margins.top = ConvertUnitDouble( print_options.paper_margins.top = ConvertUnitDouble(
requested_margins.top, desired_dpi, 1); requested_margins.top, desired_dpi, 1);
print_options.paper_margins.right = ConvertUnitDouble( print_options.paper_margins.right = ConvertUnitDouble(
requested_margins.right, desired_dpi, 1); requested_margins.right, desired_dpi, 1);
print_options.paper_margins.bottom = ConvertUnitDouble( print_options.paper_margins.bottom = ConvertUnitDouble(
requested_margins.bottom, desired_dpi, 1); requested_margins.bottom, desired_dpi, 1);
print_options.paper_margins.header = ConvertUnitDouble( print_options.paper_margins.header = ConvertUnitDouble(
requested_margins.header, desired_dpi, 1); requested_margins.header, desired_dpi, 1);
print_options.paper_margins.footer = ConvertUnitDouble( print_options.paper_margins.footer = ConvertUnitDouble(
requested_margins.footer, desired_dpi, 1); requested_margins.footer, desired_dpi, 1);
} }
void PrintSettings::UpdateFromPrintOptions(const cef_print_options_t& print_options) { void PrintSettings::UpdateFromPrintOptions(const cef_print_options_t& print_options) {
landscape = print_options.page_orientation == LANDSCAPE; landscape = print_options.page_orientation == LANDSCAPE;
page_measurements.page_type = print_options.paper_metrics.paper_type; page_measurements.page_type = print_options.paper_metrics.paper_type;
if (page_measurements.page_type == PT_CUSTOM) { if (page_measurements.page_type == PT_CUSTOM) {
page_measurements.page_length = ConvertUnitDouble( page_measurements.page_length = ConvertUnitDouble(
print_options.paper_metrics.length, 1, desired_dpi); print_options.paper_metrics.length, 1, desired_dpi);
page_measurements.page_width = ConvertUnitDouble( page_measurements.page_width = ConvertUnitDouble(
print_options.paper_metrics.width, 1, desired_dpi); print_options.paper_metrics.width, 1, desired_dpi);
} }
requested_margins.left = static_cast<int>(ConvertUnitDouble( requested_margins.left = static_cast<int>(ConvertUnitDouble(
print_options.paper_margins.left, 1, desired_dpi)); print_options.paper_margins.left, 1, desired_dpi));
requested_margins.top = static_cast<int>(ConvertUnitDouble( requested_margins.top = static_cast<int>(ConvertUnitDouble(
print_options.paper_margins.top, 1, desired_dpi)); print_options.paper_margins.top, 1, desired_dpi));
requested_margins.right = static_cast<int>(ConvertUnitDouble( requested_margins.right = static_cast<int>(ConvertUnitDouble(
print_options.paper_margins.right, 1, desired_dpi)); print_options.paper_margins.right, 1, desired_dpi));
requested_margins.bottom = static_cast<int>(ConvertUnitDouble( requested_margins.bottom = static_cast<int>(ConvertUnitDouble(
print_options.paper_margins.bottom, 1, desired_dpi)); print_options.paper_margins.bottom, 1, desired_dpi));
requested_margins.header = static_cast<int>(ConvertUnitDouble( requested_margins.header = static_cast<int>(ConvertUnitDouble(
print_options.paper_margins.header, 1, desired_dpi)); print_options.paper_margins.header, 1, desired_dpi));
requested_margins.footer = static_cast<int>(ConvertUnitDouble( requested_margins.footer = static_cast<int>(ConvertUnitDouble(
print_options.paper_margins.footer, 1, desired_dpi)); print_options.paper_margins.footer, 1, desired_dpi));
} }
} // namespace printing } // namespace printing

View File

@ -1,178 +1,178 @@
// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef _PRINTING_PRINT_SETTINGS_H #ifndef _PRINTING_PRINT_SETTINGS_H
#define _PRINTING_PRINT_SETTINGS_H #define _PRINTING_PRINT_SETTINGS_H
#include "include/cef_types.h" #include "include/cef_types.h"
#include "gfx/rect.h" #include "gfx/rect.h"
#include "printing/page_range.h" #include "printing/page_range.h"
#include "printing/page_setup.h" #include "printing/page_setup.h"
typedef struct HDC__* HDC; typedef struct HDC__* HDC;
typedef struct _devicemodeW DEVMODE; typedef struct _devicemodeW DEVMODE;
namespace printing { namespace printing {
// Parameters for a render request. // Parameters for a render request.
struct PrintParams { struct PrintParams {
// In pixels according to dpi_x and dpi_y. // In pixels according to dpi_x and dpi_y.
gfx::Size printable_size; gfx::Size printable_size;
// Specifies dots per inch. // Specifies dots per inch.
double dpi; double dpi;
// Minimum shrink factor. See PrintSettings::min_shrink for more information. // Minimum shrink factor. See PrintSettings::min_shrink for more information.
double min_shrink; double min_shrink;
// Maximum shrink factor. See PrintSettings::max_shrink for more information. // Maximum shrink factor. See PrintSettings::max_shrink for more information.
double max_shrink; double max_shrink;
// Desired apparent dpi on paper. // Desired apparent dpi on paper.
int desired_dpi; int desired_dpi;
// Cookie for the document to ensure correctness. // Cookie for the document to ensure correctness.
int document_cookie; int document_cookie;
// Indicates if the user only wants to print the current selection. // Indicates if the user only wants to print the current selection.
bool selection_only; bool selection_only;
// Indicates if the user wants to print to file. // Indicates if the user wants to print to file.
bool to_file; bool to_file;
// Warning: do not compare document_cookie. // Warning: do not compare document_cookie.
bool Equals(const PrintParams& rhs) const { bool Equals(const PrintParams& rhs) const {
return printable_size == rhs.printable_size && return printable_size == rhs.printable_size &&
dpi == rhs.dpi && dpi == rhs.dpi &&
min_shrink == rhs.min_shrink && min_shrink == rhs.min_shrink &&
max_shrink == rhs.max_shrink && max_shrink == rhs.max_shrink &&
desired_dpi == rhs.desired_dpi && desired_dpi == rhs.desired_dpi &&
selection_only == rhs.selection_only && selection_only == rhs.selection_only &&
to_file == rhs.to_file; to_file == rhs.to_file;
} }
}; };
// Page measurements information. // Page measurements information.
class PageMeasurements { class PageMeasurements {
public: public:
PageMeasurements(); PageMeasurements();
void Clear(); void Clear();
// Equality operator. // Equality operator.
bool Equals(const PageMeasurements& rhs) const; bool Equals(const PageMeasurements& rhs) const;
enum cef_paper_type_t page_type; enum cef_paper_type_t page_type;
// Page length and width represented in inches. // Page length and width represented in inches.
// These should be filled in if page_type is PT_CUSTOM. // These should be filled in if page_type is PT_CUSTOM.
double page_length; double page_length;
double page_width; double page_width;
}; };
// OS-independent print settings. // OS-independent print settings.
class PrintSettings { class PrintSettings {
public: public:
PrintSettings(); PrintSettings();
// Reinitialize the settings to the default values. // Reinitialize the settings to the default values.
void Clear(); void Clear();
#ifdef WIN32 #ifdef WIN32
// Reads the settings from the selected device context. Calculates derived // Reads the settings from the selected device context. Calculates derived
// values like printable_area_. // values like printable_area_.
void Init(HDC hdc, void Init(HDC hdc,
const DEVMODE& dev_mode, const DEVMODE& dev_mode,
const PageRanges& new_ranges, const PageRanges& new_ranges,
const std::wstring& new_device_name, const std::wstring& new_device_name,
bool selection_only, bool selection_only,
bool to_file); bool to_file);
#endif #endif
// Set printer printable area in pixels. // Set printer printable area in pixels.
void SetPrinterPrintableArea(gfx::Size const& physical_size_pixels, void SetPrinterPrintableArea(gfx::Size const& physical_size_pixels,
gfx::Rect const& printable_area_pixels); gfx::Rect const& printable_area_pixels);
// Initializes the print parameters that needs to be sent to the renderer // Initializes the print parameters that needs to be sent to the renderer
// process. // process.
void RenderParams(PrintParams* params) const; void RenderParams(PrintParams* params) const;
// Equality operator. // Equality operator.
// NOTE: printer_name is NOT tested for equality since it doesn't affect the // NOTE: printer_name is NOT tested for equality since it doesn't affect the
// output. // output.
bool Equals(const PrintSettings& rhs) const; bool Equals(const PrintSettings& rhs) const;
const std::wstring& printer_name() const { return printer_name_; } const std::wstring& printer_name() const { return printer_name_; }
void set_device_name(const std::wstring& device_name) { void set_device_name(const std::wstring& device_name) {
device_name_ = device_name; device_name_ = device_name;
} }
const std::wstring& device_name() const { return device_name_; } const std::wstring& device_name() const { return device_name_; }
int dpi() const { return dpi_; } int dpi() const { return dpi_; }
const PageSetup& page_setup_pixels() const { return page_setup_pixels_; } const PageSetup& page_setup_pixels() const { return page_setup_pixels_; }
void UpdatePrintOptions(cef_print_options_t& print_options); void UpdatePrintOptions(cef_print_options_t& print_options);
void UpdateFromPrintOptions(const cef_print_options_t& print_options); void UpdateFromPrintOptions(const cef_print_options_t& print_options);
// Multi-page printing. Each PageRange describes a from-to page combination. // Multi-page printing. Each PageRange describes a from-to page combination.
// This permits printing selected pages only. // This permits printing selected pages only.
PageRanges ranges; PageRanges ranges;
// By imaging to a width a little wider than the available pixels, thin pages // By imaging to a width a little wider than the available pixels, thin pages
// will be scaled down a little, matching the way they print in IE and Camino. // will be scaled down a little, matching the way they print in IE and Camino.
// This lets them use fewer sheets than they would otherwise, which is // This lets them use fewer sheets than they would otherwise, which is
// presumably why other browsers do this. Wide pages will be scaled down more // presumably why other browsers do this. Wide pages will be scaled down more
// than this. // than this.
double min_shrink; double min_shrink;
// This number determines how small we are willing to reduce the page content // This number determines how small we are willing to reduce the page content
// in order to accommodate the widest line. If the page would have to be // in order to accommodate the widest line. If the page would have to be
// reduced smaller to make the widest line fit, we just clip instead (this // reduced smaller to make the widest line fit, we just clip instead (this
// behavior matches MacIE and Mozilla, at least) // behavior matches MacIE and Mozilla, at least)
double max_shrink; double max_shrink;
// Desired visible dots per inch rendering for output. Printing should be // Desired visible dots per inch rendering for output. Printing should be
// scaled to ScreenDpi/dpix*desired_dpi. // scaled to ScreenDpi/dpix*desired_dpi.
int desired_dpi; int desired_dpi;
// Indicates if the user only wants to print the current selection. // Indicates if the user only wants to print the current selection.
bool selection_only; bool selection_only;
// Indicates if the user wants to print to file. // Indicates if the user wants to print to file.
bool to_file; bool to_file;
// Cookie generator. It is used to initialize PrintedDocument with its // Cookie generator. It is used to initialize PrintedDocument with its
// associated PrintSettings, to be sure that each generated PrintedPage is // associated PrintSettings, to be sure that each generated PrintedPage is
// correctly associated with its corresponding PrintedDocument. // correctly associated with its corresponding PrintedDocument.
static int NewCookie(); static int NewCookie();
// Requested Page Margins in pixels based on desired_dpi. // Requested Page Margins in pixels based on desired_dpi.
// These are in terms of desired_dpi since printer dpi may vary. // These are in terms of desired_dpi since printer dpi may vary.
PageMargins requested_margins; PageMargins requested_margins;
// Is the orientation landscape or portrait. // Is the orientation landscape or portrait.
bool landscape; bool landscape;
// Page Measurements. // Page Measurements.
PageMeasurements page_measurements; PageMeasurements page_measurements;
private: private:
void ResetRequestedPageMargins(); void ResetRequestedPageMargins();
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
// Settings that can't be changed without side-effects. // Settings that can't be changed without side-effects.
// Printer name as shown to the user. // Printer name as shown to the user.
std::wstring printer_name_; std::wstring printer_name_;
// Printer device name as opened by the OS. // Printer device name as opened by the OS.
std::wstring device_name_; std::wstring device_name_;
// Page setup in pixel units, dpi adjusted. // Page setup in pixel units, dpi adjusted.
PageSetup page_setup_pixels_; PageSetup page_setup_pixels_;
// Printer's device effective dots per inch in both axis. // Printer's device effective dots per inch in both axis.
int dpi_; int dpi_;
}; };
} // namespace printing } // namespace printing
#endif // _PRINTING_PRINT_SETTINGS_H #endif // _PRINTING_PRINT_SETTINGS_H

File diff suppressed because it is too large Load Diff

View File

@ -1,151 +1,151 @@
// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef _PRINTING_WIN_PRINTING_CONTEXT_H #ifndef _PRINTING_WIN_PRINTING_CONTEXT_H
#define _PRINTING_WIN_PRINTING_CONTEXT_H #define _PRINTING_WIN_PRINTING_CONTEXT_H
#include "print_settings.h" #include "print_settings.h"
#include <ocidl.h> #include <ocidl.h>
#include <commdlg.h> #include <commdlg.h>
#include <string> #include <string>
#include "base/basictypes.h" #include "base/basictypes.h"
namespace printing { namespace printing {
// Describe the user selected printing context for Windows. This includes the // Describe the user selected printing context for Windows. This includes the
// OS-dependent UI to ask the user about the print settings. This class directly // OS-dependent UI to ask the user about the print settings. This class directly
// talk to the printer and manages the document and pages breaks. // talk to the printer and manages the document and pages breaks.
class PrintingContext { class PrintingContext {
public: public:
// Tri-state result for user behavior-dependent functions. // Tri-state result for user behavior-dependent functions.
enum Result { enum Result {
OK, OK,
CANCEL, CANCEL,
FAILED, FAILED,
}; };
PrintingContext(); PrintingContext();
~PrintingContext(); ~PrintingContext();
// Asks the user what printer and format should be used to print. Updates the // Asks the user what printer and format should be used to print. Updates the
// context with the select device settings. // context with the select device settings.
Result AskUserForSettings(HWND window, int max_pages, bool has_selection); Result AskUserForSettings(HWND window, int max_pages, bool has_selection);
// Selects the user's default printer and format. Updates the context with the // Selects the user's default printer and format. Updates the context with the
// default device settings. // default device settings.
Result UseDefaultSettings(); Result UseDefaultSettings();
// Initializes with printer default's settings. // Initializes with printer default's settings.
Result Init(); Result Init();
// Initializes with predefined settings. // Initializes with predefined settings.
Result InitWithSettings(const PrintSettings& settings); Result InitWithSettings(const PrintSettings& settings);
// Reinitializes the settings to uninitialized for object reuse. // Reinitializes the settings to uninitialized for object reuse.
void ResetSettings(); void ResetSettings();
// Does platform specific setup of the printer before the printing. Signal the // Does platform specific setup of the printer before the printing. Signal the
// printer that a document is about to be spooled. // printer that a document is about to be spooled.
// Warning: This function enters a message loop. That may cause side effects // Warning: This function enters a message loop. That may cause side effects
// like IPC message processing! Some printers have side-effects on this call // like IPC message processing! Some printers have side-effects on this call
// like virtual printers that ask the user for the path of the saved document; // like virtual printers that ask the user for the path of the saved document;
// for example a PDF printer. // for example a PDF printer.
Result NewDocument(const std::wstring& document_name); Result NewDocument(const std::wstring& document_name);
// Starts a new page. // Starts a new page.
Result NewPage(); Result NewPage();
// Closes the printed page. // Closes the printed page.
Result PageDone(); Result PageDone();
// Closes the printing job. After this call the object is ready to start a new // Closes the printing job. After this call the object is ready to start a new
// document. // document.
Result DocumentDone(); Result DocumentDone();
// Cancels printing. Can be used in a multithreaded context. Takes effect // Cancels printing. Can be used in a multithreaded context. Takes effect
// immediately. // immediately.
void Cancel(); void Cancel();
// Dismiss the Print... dialog box if shown. // Dismiss the Print... dialog box if shown.
void DismissDialog(); void DismissDialog();
HDC context() { HDC context() {
return hdc_; return hdc_;
} }
const PrintSettings& settings() const { const PrintSettings& settings() const {
return settings_; return settings_;
} }
private: private:
// Class that manages the PrintDlgEx() callbacks. This is meant to be a // Class that manages the PrintDlgEx() callbacks. This is meant to be a
// temporary object used during the Print... dialog display. // temporary object used during the Print... dialog display.
class CallbackHandler; class CallbackHandler;
// Does bookkeeping when an error occurs. // Does bookkeeping when an error occurs.
PrintingContext::Result OnError(); PrintingContext::Result OnError();
// Used in response to the user canceling the printing. // Used in response to the user canceling the printing.
static BOOL CALLBACK AbortProc(HDC hdc, int nCode); static BOOL CALLBACK AbortProc(HDC hdc, int nCode);
// Reads the settings from the selected device context. Updates settings_ and // Reads the settings from the selected device context. Updates settings_ and
// its margins. // its margins.
bool InitializeSettings(const DEVMODE& dev_mode, bool InitializeSettings(const DEVMODE& dev_mode,
const std::wstring& new_device_name, const std::wstring& new_device_name,
const PRINTPAGERANGE* ranges, const PRINTPAGERANGE* ranges,
int number_ranges, int number_ranges,
bool selection_only, bool selection_only,
bool to_file); bool to_file);
// Retrieves the printer's default low-level settings. hdc_ is allocated with // Retrieves the printer's default low-level settings. hdc_ is allocated with
// this call. // this call.
bool GetPrinterSettings(HANDLE printer, bool GetPrinterSettings(HANDLE printer,
const std::wstring& device_name, const std::wstring& device_name,
bool adjust_dev_mode); bool adjust_dev_mode);
// Allocates the HDC for a specific DEVMODE. // Allocates the HDC for a specific DEVMODE.
bool AllocateContext(const std::wstring& printer_name, bool AllocateContext(const std::wstring& printer_name,
const DEVMODE* dev_mode); const DEVMODE* dev_mode);
// Updates printer dev_mode with settings_ // Updates printer dev_mode with settings_
void PrintingContext::AdjustDevMode(DEVMODE& dev_mode); void PrintingContext::AdjustDevMode(DEVMODE& dev_mode);
// Initializes the hdc_ either with setting_ or with just printer defaults. // Initializes the hdc_ either with setting_ or with just printer defaults.
Result Init(const std::wstring& device_name, bool adjust_dev_mode); Result Init(const std::wstring& device_name, bool adjust_dev_mode);
// Parses the result of a PRINTDLGEX result. // Parses the result of a PRINTDLGEX result.
Result ParseDialogResultEx(const PRINTDLGEX& dialog_options); Result ParseDialogResultEx(const PRINTDLGEX& dialog_options);
Result ParseDialogResult(const PRINTDLG& dialog_options); Result ParseDialogResult(const PRINTDLG& dialog_options);
// The selected printer context. // The selected printer context.
HDC hdc_; HDC hdc_;
// Complete print context settings. // Complete print context settings.
PrintSettings settings_; PrintSettings settings_;
#ifndef NDEBUG #ifndef NDEBUG
// Current page number in the print job. // Current page number in the print job.
int page_number_; int page_number_;
#endif #endif
// The dialog box for the time it is shown. // The dialog box for the time it is shown.
volatile HWND dialog_box_; volatile HWND dialog_box_;
// The dialog box has been dismissed. // The dialog box has been dismissed.
volatile bool dialog_box_dismissed_; volatile bool dialog_box_dismissed_;
// Is a print job being done. // Is a print job being done.
volatile bool in_print_job_; volatile bool in_print_job_;
// Did the user cancel the print job. // Did the user cancel the print job.
volatile bool abort_printing_; volatile bool abort_printing_;
DISALLOW_EVIL_CONSTRUCTORS(PrintingContext); DISALLOW_EVIL_CONSTRUCTORS(PrintingContext);
}; };
} // namespace printing } // namespace printing
#endif // _PRINTING_WIN_PRINTING_CONTEXT_H #endif // _PRINTING_WIN_PRINTING_CONTEXT_H

File diff suppressed because it is too large Load Diff

View File

@ -1,110 +1,110 @@
// Copyright (c) 2008-2009 The Chromium Embedded Framework Authors. All rights // Copyright (c) 2008-2009 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that // reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file. // can be found in the LICENSE file.
#ifndef _REQUEST_IMPL_H #ifndef _REQUEST_IMPL_H
#define _REQUEST_IMPL_H #define _REQUEST_IMPL_H
#include "../include/cef.h" #include "../include/cef.h"
#include "net/base/upload_data.h" #include "net/base/upload_data.h"
#include "net/http/http_request_headers.h" #include "net/http/http_request_headers.h"
#include "third_party/WebKit/WebKit/chromium/public/WebHTTPBody.h" #include "third_party/WebKit/WebKit/chromium/public/WebHTTPBody.h"
#include "third_party/WebKit/WebKit/chromium/public/WebURLRequest.h" #include "third_party/WebKit/WebKit/chromium/public/WebURLRequest.h"
class URLRequest; class URLRequest;
// Implementation of CefRequest // Implementation of CefRequest
class CefRequestImpl : public CefThreadSafeBase<CefRequest> class CefRequestImpl : public CefThreadSafeBase<CefRequest>
{ {
public: public:
CefRequestImpl(); CefRequestImpl();
~CefRequestImpl() {} ~CefRequestImpl() {}
virtual std::wstring GetURL(); virtual std::wstring GetURL();
virtual void SetURL(const std::wstring& url); virtual void SetURL(const std::wstring& url);
virtual std::wstring GetMethod(); virtual std::wstring GetMethod();
virtual void SetMethod(const std::wstring& method); virtual void SetMethod(const std::wstring& method);
virtual CefRefPtr<CefPostData> GetPostData(); virtual CefRefPtr<CefPostData> GetPostData();
virtual void SetPostData(CefRefPtr<CefPostData> postData); virtual void SetPostData(CefRefPtr<CefPostData> postData);
virtual void GetHeaderMap(HeaderMap& headerMap); virtual void GetHeaderMap(HeaderMap& headerMap);
virtual void SetHeaderMap(const HeaderMap& headerMap); virtual void SetHeaderMap(const HeaderMap& headerMap);
virtual void Set(const std::wstring& url, virtual void Set(const std::wstring& url,
const std::wstring& method, const std::wstring& method,
CefRefPtr<CefPostData> postData, CefRefPtr<CefPostData> postData,
const HeaderMap& headerMap); const HeaderMap& headerMap);
void Set(URLRequest* request); void Set(URLRequest* request);
static void GetHeaderMap(const net::HttpRequestHeaders& headers, static void GetHeaderMap(const net::HttpRequestHeaders& headers,
HeaderMap& map); HeaderMap& map);
static void GetHeaderMap(const WebKit::WebURLRequest& request, static void GetHeaderMap(const WebKit::WebURLRequest& request,
HeaderMap& map); HeaderMap& map);
static void SetHeaderMap(const HeaderMap& map, static void SetHeaderMap(const HeaderMap& map,
WebKit::WebURLRequest& request); WebKit::WebURLRequest& request);
static std::string GenerateHeaders(const HeaderMap& map); static std::string GenerateHeaders(const HeaderMap& map);
static void ParseHeaders(const std::string& header_str, HeaderMap& map); static void ParseHeaders(const std::string& header_str, HeaderMap& map);
protected: protected:
std::wstring url_; std::wstring url_;
std::wstring method_; std::wstring method_;
CefRefPtr<CefPostData> postdata_; CefRefPtr<CefPostData> postdata_;
HeaderMap headermap_; HeaderMap headermap_;
}; };
// Implementation of CefPostData // Implementation of CefPostData
class CefPostDataImpl : public CefThreadSafeBase<CefPostData> class CefPostDataImpl : public CefThreadSafeBase<CefPostData>
{ {
public: public:
CefPostDataImpl(); CefPostDataImpl();
~CefPostDataImpl() {} ~CefPostDataImpl() {}
virtual size_t GetElementCount(); virtual size_t GetElementCount();
virtual void GetElements(ElementVector& elements); virtual void GetElements(ElementVector& elements);
virtual bool RemoveElement(CefRefPtr<CefPostDataElement> element); virtual bool RemoveElement(CefRefPtr<CefPostDataElement> element);
virtual bool AddElement(CefRefPtr<CefPostDataElement> element); virtual bool AddElement(CefRefPtr<CefPostDataElement> element);
virtual void RemoveElements(); virtual void RemoveElements();
void Set(net::UploadData& data); void Set(net::UploadData& data);
void Get(net::UploadData& data); void Get(net::UploadData& data);
void Set(const WebKit::WebHTTPBody& data); void Set(const WebKit::WebHTTPBody& data);
void Get(WebKit::WebHTTPBody& data); void Get(WebKit::WebHTTPBody& data);
protected: protected:
ElementVector elements_; ElementVector elements_;
}; };
// Implementation of CefPostDataElement // Implementation of CefPostDataElement
class CefPostDataElementImpl : public CefThreadSafeBase<CefPostDataElement> class CefPostDataElementImpl : public CefThreadSafeBase<CefPostDataElement>
{ {
public: public:
CefPostDataElementImpl(); CefPostDataElementImpl();
~CefPostDataElementImpl(); ~CefPostDataElementImpl();
virtual void SetToEmpty(); virtual void SetToEmpty();
virtual void SetToFile(const std::wstring& fileName); virtual void SetToFile(const std::wstring& fileName);
virtual void SetToBytes(size_t size, const void* bytes); virtual void SetToBytes(size_t size, const void* bytes);
virtual Type GetType(); virtual Type GetType();
virtual std::wstring GetFile(); virtual std::wstring GetFile();
virtual size_t GetBytesCount(); virtual size_t GetBytesCount();
virtual size_t GetBytes(size_t size, void* bytes); virtual size_t GetBytes(size_t size, void* bytes);
void* GetBytes() { return data_.bytes.bytes; } void* GetBytes() { return data_.bytes.bytes; }
void Set(const net::UploadData::Element& element); void Set(const net::UploadData::Element& element);
void Get(net::UploadData::Element& element); void Get(net::UploadData::Element& element);
void Set(const WebKit::WebHTTPBody::Element& element); void Set(const WebKit::WebHTTPBody::Element& element);
void Get(WebKit::WebHTTPBody::Element& element); void Get(WebKit::WebHTTPBody::Element& element);
protected: protected:
Type type_; Type type_;
union { union {
struct { struct {
void* bytes; void* bytes;
size_t size; size_t size;
} bytes; } bytes;
wchar_t* filename; wchar_t* filename;
} data_; } data_;
}; };
#endif // _REQUEST_IMPL_H #endif // _REQUEST_IMPL_H

View File

@ -1,417 +1,417 @@
// Copyright (c) 2009 The Chromium Embedded Framework Authors. // Copyright (c) 2009 The Chromium Embedded Framework Authors.
// Portions copyright (c) 2006-2009 The Chromium Authors. All rights reserved. // Portions copyright (c) 2006-2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "base/lazy_instance.h" #include "base/lazy_instance.h"
#include "base/logging.h" #include "base/logging.h"
#include "base/message_loop.h" #include "base/message_loop.h"
#include "base/utf_string_conversions.h" #include "base/utf_string_conversions.h"
#include "googleurl/src/url_util.h" #include "googleurl/src/url_util.h"
#include "net/base/completion_callback.h" #include "net/base/completion_callback.h"
#include "net/base/io_buffer.h" #include "net/base/io_buffer.h"
#include "net/base/upload_data.h" #include "net/base/upload_data.h"
#include "net/http/http_util.h" #include "net/http/http_util.h"
#include "net/url_request/url_request.h" #include "net/url_request/url_request.h"
#include "net/url_request/url_request_filter.h" #include "net/url_request/url_request_filter.h"
#include "net/url_request/url_request_job.h" #include "net/url_request/url_request_job.h"
#include "include/cef.h" #include "include/cef.h"
#include "tracker.h" #include "tracker.h"
#include "cef_context.h" #include "cef_context.h"
#include "request_impl.h" #include "request_impl.h"
#include <map> #include <map>
// Memory manager. // Memory manager.
base::LazyInstance<CefTrackManager> g_scheme_tracker(base::LINKER_INITIALIZED); base::LazyInstance<CefTrackManager> g_scheme_tracker(base::LINKER_INITIALIZED);
class TrackBase : public CefTrackObject class TrackBase : public CefTrackObject
{ {
public: public:
TrackBase(CefBase* base) { base_ = base; } TrackBase(CefBase* base) { base_ = base; }
protected: protected:
CefRefPtr<CefBase> base_; CefRefPtr<CefBase> base_;
}; };
static void TrackAdd(CefTrackObject* object) static void TrackAdd(CefTrackObject* object)
{ {
g_scheme_tracker.Pointer()->Add(object); g_scheme_tracker.Pointer()->Add(object);
} }
static void TrackDelete(CefTrackObject* object) static void TrackDelete(CefTrackObject* object)
{ {
g_scheme_tracker.Pointer()->Delete(object); g_scheme_tracker.Pointer()->Delete(object);
} }
// URLRequestJob implementation. // URLRequestJob implementation.
class CefUrlRequestJob : public URLRequestJob { class CefUrlRequestJob : public URLRequestJob {
public: public:
CefUrlRequestJob(URLRequest* request, CefRefPtr<CefSchemeHandler> handler) CefUrlRequestJob(URLRequest* request, CefRefPtr<CefSchemeHandler> handler)
: URLRequestJob(request), : URLRequestJob(request),
url_(request->url()), url_(request->url()),
handler_(handler), handler_(handler),
response_length_(0), response_length_(0),
remaining_bytes_(0) { } remaining_bytes_(0) { }
virtual ~CefUrlRequestJob(){} virtual ~CefUrlRequestJob(){}
virtual void Start() virtual void Start()
{ {
handler_->Cancel(); handler_->Cancel();
// Continue asynchronously. // Continue asynchronously.
DCHECK(!async_resolver_); DCHECK(!async_resolver_);
async_resolver_ = new AsyncResolver(this); async_resolver_ = new AsyncResolver(this);
CefThread::PostTask(CefThread::IO, FROM_HERE, NewRunnableMethod( CefThread::PostTask(CefThread::IO, FROM_HERE, NewRunnableMethod(
async_resolver_.get(), &AsyncResolver::Resolve, url_)); async_resolver_.get(), &AsyncResolver::Resolve, url_));
return; return;
} }
virtual void Kill() virtual void Kill()
{ {
if (async_resolver_) { if (async_resolver_) {
async_resolver_->Cancel(); async_resolver_->Cancel();
async_resolver_ = NULL; async_resolver_ = NULL;
} }
URLRequestJob::Kill(); URLRequestJob::Kill();
} }
virtual bool ReadRawData(net::IOBuffer* dest, int dest_size, int *bytes_read) virtual bool ReadRawData(net::IOBuffer* dest, int dest_size, int *bytes_read)
{ {
DCHECK_NE(dest_size, 0); DCHECK_NE(dest_size, 0);
DCHECK(bytes_read); DCHECK(bytes_read);
// When remaining_bytes_>=0, it means the handler knows the content size // When remaining_bytes_>=0, it means the handler knows the content size
// before hand. We continue to read until // before hand. We continue to read until
if (remaining_bytes_>=0) { if (remaining_bytes_>=0) {
if (remaining_bytes_ < dest_size) if (remaining_bytes_ < dest_size)
dest_size = static_cast<int>(remaining_bytes_); dest_size = static_cast<int>(remaining_bytes_);
// If we should copy zero bytes because |remaining_bytes_| is zero, short // If we should copy zero bytes because |remaining_bytes_| is zero, short
// circuit here. // circuit here.
if (!dest_size) { if (!dest_size) {
*bytes_read = 0; *bytes_read = 0;
return true; return true;
} }
// remaining_bytes > 0 // remaining_bytes > 0
bool rv = handler_->ReadResponse(dest->data(), dest_size, bytes_read); bool rv = handler_->ReadResponse(dest->data(), dest_size, bytes_read);
remaining_bytes_ -= *bytes_read; remaining_bytes_ -= *bytes_read;
if (!rv) { if (!rv) {
// handler indicated no further data to read // handler indicated no further data to read
*bytes_read = 0; *bytes_read = 0;
} }
return true; return true;
} else { } else {
// The handler returns -1 for GetResponseLength, this means the handler // The handler returns -1 for GetResponseLength, this means the handler
// doesn't know the content size before hand. We do basically the same // doesn't know the content size before hand. We do basically the same
// thing, except for checking the return value for handler_->ReadResponse, // thing, except for checking the return value for handler_->ReadResponse,
// which is an indicator for no further data to be read. // which is an indicator for no further data to be read.
bool rv = handler_->ReadResponse(dest->data(), dest_size, bytes_read); bool rv = handler_->ReadResponse(dest->data(), dest_size, bytes_read);
if (!rv) if (!rv)
// handler indicated no further data to read // handler indicated no further data to read
*bytes_read = 0; *bytes_read = 0;
return true; return true;
} }
} }
virtual bool IsRedirectResponse(GURL* location, int* http_status_code) virtual bool IsRedirectResponse(GURL* location, int* http_status_code)
{ {
return false; return false;
} }
virtual bool GetContentEncodings( virtual bool GetContentEncodings(
std::vector<Filter::FilterType>* encoding_types) std::vector<Filter::FilterType>* encoding_types)
{ {
DCHECK(encoding_types->empty()); DCHECK(encoding_types->empty());
return !encoding_types->empty(); return !encoding_types->empty();
} }
virtual bool GetMimeType(std::string* mime_type) const virtual bool GetMimeType(std::string* mime_type) const
{ {
DCHECK(request_); DCHECK(request_);
// call handler to get mime type // call handler to get mime type
*mime_type = mime_type_; *mime_type = mime_type_;
return true; return true;
} }
virtual void SetExtraRequestHeaders(const std::string& headers) virtual void SetExtraRequestHeaders(const std::string& headers)
{ {
} }
CefRefPtr<CefSchemeHandler> handler_; CefRefPtr<CefSchemeHandler> handler_;
std::string mime_type_; std::string mime_type_;
int response_length_; int response_length_;
protected: protected:
GURL url_; GURL url_;
private: private:
void DidResolve(const GURL& url) void DidResolve(const GURL& url)
{ {
async_resolver_ = NULL; async_resolver_ = NULL;
// We may have been orphaned... // We may have been orphaned...
if (!request_) if (!request_)
return; return;
remaining_bytes_ = response_length_; remaining_bytes_ = response_length_;
if (remaining_bytes_>0) if (remaining_bytes_>0)
set_expected_content_size(remaining_bytes_); set_expected_content_size(remaining_bytes_);
NotifyHeadersComplete(); NotifyHeadersComplete();
} }
int64 remaining_bytes_; int64 remaining_bytes_;
std::string m_response; std::string m_response;
class AsyncResolver : class AsyncResolver :
public base::RefCountedThreadSafe<AsyncResolver> { public base::RefCountedThreadSafe<AsyncResolver> {
public: public:
explicit AsyncResolver(CefUrlRequestJob* owner) explicit AsyncResolver(CefUrlRequestJob* owner)
: owner_(owner), owner_loop_(MessageLoop::current()) { : owner_(owner), owner_loop_(MessageLoop::current()) {
} }
void Resolve(const GURL& url) { void Resolve(const GURL& url) {
AutoLock locked(lock_); AutoLock locked(lock_);
if (!owner_ || !owner_loop_) if (!owner_ || !owner_loop_)
return; return;
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
// safe to perform long operation here // safe to perform long operation here
CefRefPtr<CefRequest> req(CefRequest::CreateRequest()); CefRefPtr<CefRequest> req(CefRequest::CreateRequest());
// populate the request data // populate the request data
static_cast<CefRequestImpl*>(req.get())->Set(owner_->request()); static_cast<CefRequestImpl*>(req.get())->Set(owner_->request());
owner_->handler_->Cancel(); owner_->handler_->Cancel();
std::wstring mime_type; std::wstring mime_type;
int response_length = 0; int response_length = 0;
// handler should complete content generation in ProcessRequest // handler should complete content generation in ProcessRequest
bool res = owner_->handler_->ProcessRequest(req, mime_type, bool res = owner_->handler_->ProcessRequest(req, mime_type,
&response_length); &response_length);
if (res) { if (res) {
owner_->mime_type_ = WideToUTF8(mime_type); owner_->mime_type_ = WideToUTF8(mime_type);
owner_->response_length_ = response_length; owner_->response_length_ = response_length;
} }
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
if (owner_loop_) { if (owner_loop_) {
owner_loop_->PostTask(FROM_HERE, NewRunnableMethod( owner_loop_->PostTask(FROM_HERE, NewRunnableMethod(
this, &AsyncResolver::ReturnResults, url)); this, &AsyncResolver::ReturnResults, url));
} }
} }
void Cancel() { void Cancel() {
owner_->handler_->Cancel(); owner_->handler_->Cancel();
AutoLock locked(lock_); AutoLock locked(lock_);
owner_ = NULL; owner_ = NULL;
owner_loop_ = NULL; owner_loop_ = NULL;
} }
private: private:
void ReturnResults(const GURL& url) { void ReturnResults(const GURL& url) {
if (owner_) if (owner_)
owner_->DidResolve(url); owner_->DidResolve(url);
} }
CefUrlRequestJob* owner_; CefUrlRequestJob* owner_;
Lock lock_; Lock lock_;
MessageLoop* owner_loop_; MessageLoop* owner_loop_;
}; };
friend class AsyncResolver; friend class AsyncResolver;
scoped_refptr<AsyncResolver> async_resolver_; scoped_refptr<AsyncResolver> async_resolver_;
DISALLOW_COPY_AND_ASSIGN(CefUrlRequestJob); DISALLOW_COPY_AND_ASSIGN(CefUrlRequestJob);
}; };
// URLRequestFilter clone that manages the CefSchemeHandlerFactory pointers. // URLRequestFilter clone that manages the CefSchemeHandlerFactory pointers.
class CefUrlRequestFilter { class CefUrlRequestFilter {
public: public:
// scheme,hostname -> ProtocolFactory // scheme,hostname -> ProtocolFactory
typedef std::map<std::pair<std::string, std::string>, typedef std::map<std::pair<std::string, std::string>,
CefSchemeHandlerFactory*> HandlerMap; CefSchemeHandlerFactory*> HandlerMap;
// Singleton instance for use. // Singleton instance for use.
static CefUrlRequestFilter* GetInstance() static CefUrlRequestFilter* GetInstance()
{ {
if (!shared_instance_) if (!shared_instance_)
shared_instance_ = new CefUrlRequestFilter; shared_instance_ = new CefUrlRequestFilter;
return shared_instance_; return shared_instance_;
} }
static URLRequestJob* Factory(URLRequest* request, static URLRequestJob* Factory(URLRequest* request,
const std::string& scheme) const std::string& scheme)
{ {
// Returning null here just means that the built-in handler will be used. // Returning null here just means that the built-in handler will be used.
return GetInstance()->FindRequestHandler(request, scheme); return GetInstance()->FindRequestHandler(request, scheme);
} }
void AddHostnameHandler(const std::string& scheme, void AddHostnameHandler(const std::string& scheme,
const std::string& hostname, const std::string& hostname,
CefSchemeHandlerFactory* factory) CefSchemeHandlerFactory* factory)
{ {
handler_map_[make_pair(scheme, hostname)] = factory; handler_map_[make_pair(scheme, hostname)] = factory;
// Register with the ProtocolFactory. // Register with the ProtocolFactory.
URLRequest::RegisterProtocolFactory(scheme, URLRequest::RegisterProtocolFactory(scheme,
&CefUrlRequestFilter::Factory); &CefUrlRequestFilter::Factory);
} }
void RemoveHostnameHandler(const std::string& scheme, void RemoveHostnameHandler(const std::string& scheme,
const std::string& hostname) const std::string& hostname)
{ {
HandlerMap::iterator iter = HandlerMap::iterator iter =
handler_map_.find(make_pair(scheme, hostname)); handler_map_.find(make_pair(scheme, hostname));
DCHECK(iter != handler_map_.end()); DCHECK(iter != handler_map_.end());
handler_map_.erase(iter); handler_map_.erase(iter);
} }
// Clear all the existing URL handlers and unregister with the // Clear all the existing URL handlers and unregister with the
// ProtocolFactory. Resets the hit count. // ProtocolFactory. Resets the hit count.
void ClearHandlers() void ClearHandlers()
{ {
// Unregister with the ProtocolFactory. // Unregister with the ProtocolFactory.
std::set<std::string> schemes; std::set<std::string> schemes;
for (HandlerMap::const_iterator i = handler_map_.begin(); for (HandlerMap::const_iterator i = handler_map_.begin();
i != handler_map_.end(); ++i) { i != handler_map_.end(); ++i) {
schemes.insert(i->first.first); schemes.insert(i->first.first);
} }
for (std::set<std::string>::const_iterator scheme = schemes.begin(); for (std::set<std::string>::const_iterator scheme = schemes.begin();
scheme != schemes.end(); ++scheme) { scheme != schemes.end(); ++scheme) {
URLRequest::RegisterProtocolFactory(*scheme, NULL); URLRequest::RegisterProtocolFactory(*scheme, NULL);
} }
handler_map_.clear(); handler_map_.clear();
hit_count_ = 0; hit_count_ = 0;
} }
CefSchemeHandlerFactory* FindRequestHandlerFactory(URLRequest* request, CefSchemeHandlerFactory* FindRequestHandlerFactory(URLRequest* request,
const std::string& scheme) const std::string& scheme)
{ {
CefSchemeHandlerFactory* factory = NULL; CefSchemeHandlerFactory* factory = NULL;
if (request->url().is_valid()) { if (request->url().is_valid()) {
// Check for a map with a hostname first. // Check for a map with a hostname first.
const std::string& hostname = request->url().host(); const std::string& hostname = request->url().host();
HandlerMap::iterator i = handler_map_.find(make_pair(scheme, hostname)); HandlerMap::iterator i = handler_map_.find(make_pair(scheme, hostname));
if (i != handler_map_.end()) if (i != handler_map_.end())
factory = i->second; factory = i->second;
} }
if (!factory) { if (!factory) {
// Check for a map with no specified hostname. // Check for a map with no specified hostname.
HandlerMap::iterator i = HandlerMap::iterator i =
handler_map_.find(make_pair(scheme, std::string())); handler_map_.find(make_pair(scheme, std::string()));
if (i != handler_map_.end()) if (i != handler_map_.end())
factory = i->second; factory = i->second;
} }
return factory; return factory;
} }
// Returns the number of times a handler was used to service a request. // Returns the number of times a handler was used to service a request.
int hit_count() const { return hit_count_; } int hit_count() const { return hit_count_; }
protected: protected:
CefUrlRequestFilter() : hit_count_(0) { } CefUrlRequestFilter() : hit_count_(0) { }
// Helper method that looks up the request in the handler_map_. // Helper method that looks up the request in the handler_map_.
URLRequestJob* FindRequestHandler(URLRequest* request, URLRequestJob* FindRequestHandler(URLRequest* request,
const std::string& scheme) const std::string& scheme)
{ {
URLRequestJob* job = NULL; URLRequestJob* job = NULL;
CefSchemeHandlerFactory* factory = CefSchemeHandlerFactory* factory =
FindRequestHandlerFactory(request, scheme); FindRequestHandlerFactory(request, scheme);
if (factory) { if (factory) {
CefRefPtr<CefSchemeHandler> handler = factory->Create(); CefRefPtr<CefSchemeHandler> handler = factory->Create();
if (handler.get()) if (handler.get())
job = new CefUrlRequestJob(request, handler); job = new CefUrlRequestJob(request, handler);
} }
if (job) { if (job) {
DLOG(INFO) << "URLRequestFilter hit for " << request->url().spec(); DLOG(INFO) << "URLRequestFilter hit for " << request->url().spec();
hit_count_++; hit_count_++;
} }
return job; return job;
} }
// Maps hostnames to factories. Hostnames take priority over URLs. // Maps hostnames to factories. Hostnames take priority over URLs.
HandlerMap handler_map_; HandlerMap handler_map_;
int hit_count_; int hit_count_;
private: private:
// Singleton instance. // Singleton instance.
static CefUrlRequestFilter* shared_instance_; static CefUrlRequestFilter* shared_instance_;
DISALLOW_EVIL_CONSTRUCTORS(CefUrlRequestFilter); DISALLOW_EVIL_CONSTRUCTORS(CefUrlRequestFilter);
}; };
CefUrlRequestFilter* CefUrlRequestFilter::shared_instance_ = NULL; CefUrlRequestFilter* CefUrlRequestFilter::shared_instance_ = NULL;
class SchemeRequestJobWrapper : public CefThreadSafeBase<CefBase> { class SchemeRequestJobWrapper : public CefThreadSafeBase<CefBase> {
public: public:
SchemeRequestJobWrapper(const std::string& scheme_name, SchemeRequestJobWrapper(const std::string& scheme_name,
const std::string& host_name, const std::string& host_name,
CefSchemeHandlerFactory* factory) CefSchemeHandlerFactory* factory)
: factory_(factory), scheme_name_(scheme_name), host_name_(host_name) : factory_(factory), scheme_name_(scheme_name), host_name_(host_name)
{ {
// The reference will be released when the application exits. // The reference will be released when the application exits.
TrackAdd(new TrackBase(factory)); TrackAdd(new TrackBase(factory));
} }
void RegisterScheme() void RegisterScheme()
{ {
// Register the scheme as a standard scheme if it isn't already. // Register the scheme as a standard scheme if it isn't already.
url_parse::Component scheme(0, scheme_name_.length()); url_parse::Component scheme(0, scheme_name_.length());
if (!url_util::IsStandard(scheme_name_.c_str(), scheme)) if (!url_util::IsStandard(scheme_name_.c_str(), scheme))
url_util::AddStandardScheme(scheme_name_.c_str()); url_util::AddStandardScheme(scheme_name_.c_str());
// we need to store the pointer of this handler because // we need to store the pointer of this handler because
// we can't pass it as a parameter to the factory method // we can't pass it as a parameter to the factory method
CefUrlRequestFilter::GetInstance()->AddHostnameHandler( CefUrlRequestFilter::GetInstance()->AddHostnameHandler(
scheme_name_, host_name_, factory_); scheme_name_, host_name_, factory_);
} }
static bool ImplementsThreadSafeReferenceCounting() { return true; } static bool ImplementsThreadSafeReferenceCounting() { return true; }
private: private:
CefSchemeHandlerFactory* factory_; CefSchemeHandlerFactory* factory_;
std::string scheme_name_; std::string scheme_name_;
std::string host_name_; std::string host_name_;
}; };
bool CefRegisterScheme(const std::wstring& scheme_name, bool CefRegisterScheme(const std::wstring& scheme_name,
const std::wstring& host_name, const std::wstring& host_name,
CefRefPtr<CefSchemeHandlerFactory> factory) CefRefPtr<CefSchemeHandlerFactory> factory)
{ {
// Verify that the context is already initialized // Verify that the context is already initialized
if(!_Context.get()) if(!_Context.get())
return false; return false;
// Use a smart pointer for the wrapper object because // Use a smart pointer for the wrapper object because
// RunnableMethodTraits::RetainCallee() (originating from NewRunnableMethod) // RunnableMethodTraits::RetainCallee() (originating from NewRunnableMethod)
// will call AddRef() and Release() on the object in debug mode, resulting in // will call AddRef() and Release() on the object in debug mode, resulting in
// the object being deleted if it doesn't already have a reference. // the object being deleted if it doesn't already have a reference.
CefRefPtr<SchemeRequestJobWrapper> wrapper( CefRefPtr<SchemeRequestJobWrapper> wrapper(
new SchemeRequestJobWrapper(WideToUTF8(scheme_name), new SchemeRequestJobWrapper(WideToUTF8(scheme_name),
WideToUTF8(host_name), factory)); WideToUTF8(host_name), factory));
CefThread::PostTask(CefThread::UI, FROM_HERE, NewRunnableMethod(wrapper.get(), CefThread::PostTask(CefThread::UI, FROM_HERE, NewRunnableMethod(wrapper.get(),
&SchemeRequestJobWrapper::RegisterScheme)); &SchemeRequestJobWrapper::RegisterScheme));
return true; return true;
} }

View File

@ -1,356 +1,356 @@
// Copyright (c) 2008 The Chromium Embedded Framework Authors. All rights // Copyright (c) 2008 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that // reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file. // can be found in the LICENSE file.
#include "stream_impl.h" #include "stream_impl.h"
#include "base/logging.h" #include "base/logging.h"
// Static functions // Static functions
CefRefPtr<CefStreamReader> CefStreamReader::CreateForFile( CefRefPtr<CefStreamReader> CefStreamReader::CreateForFile(
const std::wstring& fileName) const std::wstring& fileName)
{ {
CefRefPtr<CefStreamReader> reader; CefRefPtr<CefStreamReader> reader;
FILE *f = _wfopen(fileName.c_str(), L"rb"); FILE *f = _wfopen(fileName.c_str(), L"rb");
if(f) if(f)
reader = new CefFileReader(f, true); reader = new CefFileReader(f, true);
return reader; return reader;
} }
CefRefPtr<CefStreamReader> CefStreamReader::CreateForData(void* data, CefRefPtr<CefStreamReader> CefStreamReader::CreateForData(void* data,
size_t size) size_t size)
{ {
DCHECK(data != NULL); DCHECK(data != NULL);
DCHECK(size > 0); DCHECK(size > 0);
CefRefPtr<CefStreamReader> reader; CefRefPtr<CefStreamReader> reader;
if(data && size > 0) if(data && size > 0)
reader = new CefBytesReader(data, size, true); reader = new CefBytesReader(data, size, true);
return reader; return reader;
} }
CefRefPtr<CefStreamReader> CefStreamReader::CreateForHandler( CefRefPtr<CefStreamReader> CefStreamReader::CreateForHandler(
CefRefPtr<CefReadHandler> handler) CefRefPtr<CefReadHandler> handler)
{ {
DCHECK(handler.get()); DCHECK(handler.get());
CefRefPtr<CefStreamReader> reader; CefRefPtr<CefStreamReader> reader;
if(handler.get()) if(handler.get())
reader = new CefHandlerReader(handler); reader = new CefHandlerReader(handler);
return reader; return reader;
} }
CefRefPtr<CefStreamWriter> CefStreamWriter::CreateForFile( CefRefPtr<CefStreamWriter> CefStreamWriter::CreateForFile(
const std::wstring& fileName) const std::wstring& fileName)
{ {
DCHECK(!fileName.empty()); DCHECK(!fileName.empty());
CefRefPtr<CefStreamWriter> writer; CefRefPtr<CefStreamWriter> writer;
FILE* file = _wfopen(fileName.c_str(), L"wb"); FILE* file = _wfopen(fileName.c_str(), L"wb");
if(file) if(file)
writer = new CefFileWriter(file, true); writer = new CefFileWriter(file, true);
return writer; return writer;
} }
CefRefPtr<CefStreamWriter> CefStreamWriter::CreateForHandler( CefRefPtr<CefStreamWriter> CefStreamWriter::CreateForHandler(
CefRefPtr<CefWriteHandler> handler) CefRefPtr<CefWriteHandler> handler)
{ {
DCHECK(handler.get()); DCHECK(handler.get());
CefRefPtr<CefStreamWriter> writer; CefRefPtr<CefStreamWriter> writer;
if(handler.get()) if(handler.get())
writer = new CefHandlerWriter(handler); writer = new CefHandlerWriter(handler);
return writer; return writer;
} }
// CefFileReader // CefFileReader
CefFileReader::CefFileReader(FILE* file, bool close) CefFileReader::CefFileReader(FILE* file, bool close)
: file_(file), close_(close) : file_(file), close_(close)
{ {
} }
CefFileReader::~CefFileReader() CefFileReader::~CefFileReader()
{ {
Lock(); Lock();
if(close_) if(close_)
fclose(file_); fclose(file_);
Unlock(); Unlock();
} }
size_t CefFileReader::Read(void* ptr, size_t size, size_t n) size_t CefFileReader::Read(void* ptr, size_t size, size_t n)
{ {
Lock(); Lock();
size_t rv = fread(ptr, size, n, file_); size_t rv = fread(ptr, size, n, file_);
Unlock(); Unlock();
return rv; return rv;
} }
int CefFileReader::Seek(long offset, int whence) int CefFileReader::Seek(long offset, int whence)
{ {
Lock(); Lock();
int rv = fseek(file_, offset, whence); int rv = fseek(file_, offset, whence);
Unlock(); Unlock();
return rv; return rv;
} }
long CefFileReader::Tell() long CefFileReader::Tell()
{ {
Lock(); Lock();
long rv = ftell(file_); long rv = ftell(file_);
Unlock(); Unlock();
return rv; return rv;
} }
int CefFileReader::Eof() int CefFileReader::Eof()
{ {
Lock(); Lock();
int rv = feof(file_); int rv = feof(file_);
Unlock(); Unlock();
return rv; return rv;
} }
// CefFileWriter // CefFileWriter
CefFileWriter::CefFileWriter(FILE* file, bool close) CefFileWriter::CefFileWriter(FILE* file, bool close)
: file_(file), close_(close) : file_(file), close_(close)
{ {
} }
CefFileWriter::~CefFileWriter() CefFileWriter::~CefFileWriter()
{ {
Lock(); Lock();
if(close_) if(close_)
fclose(file_); fclose(file_);
Unlock(); Unlock();
} }
size_t CefFileWriter::Write(const void* ptr, size_t size, size_t n) size_t CefFileWriter::Write(const void* ptr, size_t size, size_t n)
{ {
Lock(); Lock();
size_t rv = (size_t)fwrite(ptr, size, n, file_); size_t rv = (size_t)fwrite(ptr, size, n, file_);
Unlock(); Unlock();
return rv; return rv;
} }
int CefFileWriter::Seek(long offset, int whence) int CefFileWriter::Seek(long offset, int whence)
{ {
Lock(); Lock();
int rv = fseek(file_, offset, whence); int rv = fseek(file_, offset, whence);
Unlock(); Unlock();
return rv; return rv;
} }
long CefFileWriter::Tell() long CefFileWriter::Tell()
{ {
Lock(); Lock();
long rv = ftell(file_); long rv = ftell(file_);
Unlock(); Unlock();
return rv; return rv;
} }
int CefFileWriter::Flush() int CefFileWriter::Flush()
{ {
Lock(); Lock();
int rv = fflush(file_); int rv = fflush(file_);
Unlock(); Unlock();
return rv; return rv;
} }
// CefBytesReader // CefBytesReader
CefBytesReader::CefBytesReader(void* data, long datasize, bool copy) CefBytesReader::CefBytesReader(void* data, long datasize, bool copy)
: data_(NULL), datasize_(0), copy_(false), offset_(0) : data_(NULL), datasize_(0), copy_(false), offset_(0)
{ {
SetData(data, datasize, copy); SetData(data, datasize, copy);
} }
CefBytesReader::~CefBytesReader() CefBytesReader::~CefBytesReader()
{ {
SetData(NULL, 0, false); SetData(NULL, 0, false);
} }
size_t CefBytesReader::Read(void* ptr, size_t size, size_t n) size_t CefBytesReader::Read(void* ptr, size_t size, size_t n)
{ {
Lock(); Lock();
size_t s = (datasize_ - offset_) / size; size_t s = (datasize_ - offset_) / size;
size_t ret = (n < s ? n : s); size_t ret = (n < s ? n : s);
memcpy(ptr, ((char*)data_) + offset_, ret * size); memcpy(ptr, ((char*)data_) + offset_, ret * size);
offset_ += ret * size; offset_ += ret * size;
Unlock(); Unlock();
return ret; return ret;
} }
int CefBytesReader::Seek(long offset, int whence) int CefBytesReader::Seek(long offset, int whence)
{ {
int rv = -1L; int rv = -1L;
Lock(); Lock();
switch(whence) { switch(whence) {
case SEEK_CUR: case SEEK_CUR:
if(offset_ + offset > datasize_) { if(offset_ + offset > datasize_) {
break; break;
} }
offset_ += offset; offset_ += offset;
rv = 0; rv = 0;
break; break;
case SEEK_END: case SEEK_END:
if(offset > (int)datasize_) { if(offset > (int)datasize_) {
break; break;
} }
offset_ = datasize_ - offset; offset_ = datasize_ - offset;
rv = 0; rv = 0;
break; break;
case SEEK_SET: case SEEK_SET:
if(offset > (int)datasize_) { if(offset > (int)datasize_) {
break; break;
} }
offset_ = offset; offset_ = offset;
rv = 0; rv = 0;
break; break;
} }
Unlock(); Unlock();
return rv; return rv;
} }
long CefBytesReader::Tell() long CefBytesReader::Tell()
{ {
Lock(); Lock();
long rv = offset_; long rv = offset_;
Unlock(); Unlock();
return rv; return rv;
} }
int CefBytesReader::Eof() int CefBytesReader::Eof()
{ {
Lock(); Lock();
int rv = (offset_ >= datasize_); int rv = (offset_ >= datasize_);
Unlock(); Unlock();
return rv; return rv;
} }
void CefBytesReader::SetData(void* data, long datasize, bool copy) void CefBytesReader::SetData(void* data, long datasize, bool copy)
{ {
Lock(); Lock();
if(copy_) if(copy_)
free(data_); free(data_);
copy_ = copy; copy_ = copy;
offset_ = 0; offset_ = 0;
datasize_ = datasize; datasize_ = datasize;
if(copy) { if(copy) {
data_ = malloc(datasize); data_ = malloc(datasize);
DCHECK(data_ != NULL); DCHECK(data_ != NULL);
if(data_) if(data_)
memcpy(data_, data, datasize); memcpy(data_, data, datasize);
} else { } else {
data_ = data; data_ = data;
} }
Unlock(); Unlock();
} }
// CefBytesWriter // CefBytesWriter
CefBytesWriter::CefBytesWriter(size_t grow) CefBytesWriter::CefBytesWriter(size_t grow)
: grow_(grow), offset_(0), datasize_(grow) : grow_(grow), offset_(0), datasize_(grow)
{ {
DCHECK(grow > 0); DCHECK(grow > 0);
data_ = malloc(grow); data_ = malloc(grow);
DCHECK(data_ != NULL); DCHECK(data_ != NULL);
} }
CefBytesWriter::~CefBytesWriter() CefBytesWriter::~CefBytesWriter()
{ {
Lock(); Lock();
if(data_) if(data_)
free(data_); free(data_);
Unlock(); Unlock();
} }
size_t CefBytesWriter::Write(const void* ptr, size_t size, size_t n) size_t CefBytesWriter::Write(const void* ptr, size_t size, size_t n)
{ {
Lock(); Lock();
size_t rv; size_t rv;
if(offset_ + size * n >= datasize_ && Grow(size * n) == 0) { if(offset_ + size * n >= datasize_ && Grow(size * n) == 0) {
rv = 0; rv = 0;
} else { } else {
memcpy(((char*)data_) + offset_, ptr, size * n); memcpy(((char*)data_) + offset_, ptr, size * n);
offset_ += size * n; offset_ += size * n;
rv = n; rv = n;
} }
Unlock(); Unlock();
return rv; return rv;
} }
int CefBytesWriter::Seek(long offset, int whence) int CefBytesWriter::Seek(long offset, int whence)
{ {
int rv = -1L; int rv = -1L;
Lock(); Lock();
switch(whence) { switch(whence) {
case SEEK_CUR: case SEEK_CUR:
if(offset_ + offset > datasize_) { if(offset_ + offset > datasize_) {
break; break;
} }
offset_ += offset; offset_ += offset;
rv = offset_; rv = offset_;
break; break;
case SEEK_END: case SEEK_END:
if(offset > (int)datasize_) { if(offset > (int)datasize_) {
break; break;
} }
offset_ = datasize_ - offset; offset_ = datasize_ - offset;
rv = offset_; rv = offset_;
case SEEK_SET: case SEEK_SET:
if(offset > (int)datasize_) { if(offset > (int)datasize_) {
break; break;
} }
offset_ = offset; offset_ = offset;
rv = offset_; rv = offset_;
break; break;
} }
Unlock(); Unlock();
return rv; return rv;
} }
long CefBytesWriter::Tell() long CefBytesWriter::Tell()
{ {
Lock(); Lock();
long rv = offset_; long rv = offset_;
Unlock(); Unlock();
return rv; return rv;
} }
int CefBytesWriter::Flush() int CefBytesWriter::Flush()
{ {
return 0; return 0;
} }
std::string CefBytesWriter::GetDataString() std::string CefBytesWriter::GetDataString()
{ {
Lock(); Lock();
std::string str((char*)data_, offset_); std::string str((char*)data_, offset_);
Unlock(); Unlock();
return str; return str;
} }
size_t CefBytesWriter::Grow(size_t size) size_t CefBytesWriter::Grow(size_t size)
{ {
Lock(); Lock();
size_t rv; size_t rv;
size_t s = (size > grow_ ? size : grow_); size_t s = (size > grow_ ? size : grow_);
void* tmp = realloc(data_, datasize_ + s); void* tmp = realloc(data_, datasize_ + s);
DCHECK(tmp != NULL); DCHECK(tmp != NULL);
if(tmp) { if(tmp) {
data_ = tmp; data_ = tmp;
datasize_ += s; datasize_ += s;
rv = datasize_; rv = datasize_;
} else { } else {
rv = 0; rv = 0;
} }
Unlock(); Unlock();
return rv; return rv;
} }

View File

@ -1,149 +1,149 @@
// Copyright (c) 2008 The Chromium Embedded Framework Authors. All rights // Copyright (c) 2008 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that // reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file. // can be found in the LICENSE file.
#ifndef _STREAM_IMPL_H #ifndef _STREAM_IMPL_H
#define _STREAM_IMPL_H #define _STREAM_IMPL_H
#include "../include/cef.h" #include "../include/cef.h"
#include <stdio.h> #include <stdio.h>
// Implementation of CefStreamReader for files. // Implementation of CefStreamReader for files.
class CefFileReader : public CefThreadSafeBase<CefStreamReader> class CefFileReader : public CefThreadSafeBase<CefStreamReader>
{ {
public: public:
CefFileReader(FILE* file, bool close); CefFileReader(FILE* file, bool close);
virtual ~CefFileReader(); virtual ~CefFileReader();
virtual size_t Read(void* ptr, size_t size, size_t n); virtual size_t Read(void* ptr, size_t size, size_t n);
virtual int Seek(long offset, int whence); virtual int Seek(long offset, int whence);
virtual long Tell(); virtual long Tell();
virtual int Eof(); virtual int Eof();
protected: protected:
bool close_; bool close_;
FILE *file_; FILE *file_;
}; };
// Implementation of CefStreamWriter for files. // Implementation of CefStreamWriter for files.
class CefFileWriter : public CefThreadSafeBase<CefStreamWriter> class CefFileWriter : public CefThreadSafeBase<CefStreamWriter>
{ {
public: public:
CefFileWriter(FILE* file, bool close); CefFileWriter(FILE* file, bool close);
virtual ~CefFileWriter(); virtual ~CefFileWriter();
virtual size_t Write(const void* ptr, size_t size, size_t n); virtual size_t Write(const void* ptr, size_t size, size_t n);
virtual int Seek(long offset, int whence); virtual int Seek(long offset, int whence);
virtual long Tell(); virtual long Tell();
virtual int Flush(); virtual int Flush();
protected: protected:
FILE *file_; FILE *file_;
bool close_; bool close_;
}; };
// Implementation of CefStreamReader for byte buffers. // Implementation of CefStreamReader for byte buffers.
class CefBytesReader : public CefThreadSafeBase<CefStreamReader> class CefBytesReader : public CefThreadSafeBase<CefStreamReader>
{ {
public: public:
CefBytesReader(void* data, long datasize, bool copy); CefBytesReader(void* data, long datasize, bool copy);
virtual ~CefBytesReader(); virtual ~CefBytesReader();
virtual size_t Read(void* ptr, size_t size, size_t n); virtual size_t Read(void* ptr, size_t size, size_t n);
virtual int Seek(long offset, int whence); virtual int Seek(long offset, int whence);
virtual long Tell(); virtual long Tell();
virtual int Eof(); virtual int Eof();
void SetData(void* data, long datasize, bool copy); void SetData(void* data, long datasize, bool copy);
void* GetData() { return data_; } void* GetData() { return data_; }
size_t GetDataSize() { return offset_; } size_t GetDataSize() { return offset_; }
protected: protected:
void* data_; void* data_;
size_t datasize_; size_t datasize_;
bool copy_; bool copy_;
size_t offset_; size_t offset_;
}; };
// Implementation of CefStreamWriter for byte buffers. // Implementation of CefStreamWriter for byte buffers.
class CefBytesWriter : public CefThreadSafeBase<CefStreamWriter> class CefBytesWriter : public CefThreadSafeBase<CefStreamWriter>
{ {
public: public:
CefBytesWriter(size_t grow); CefBytesWriter(size_t grow);
virtual ~CefBytesWriter(); virtual ~CefBytesWriter();
virtual size_t Write(const void* ptr, size_t size, size_t n); virtual size_t Write(const void* ptr, size_t size, size_t n);
virtual int Seek(long offset, int whence); virtual int Seek(long offset, int whence);
virtual long Tell(); virtual long Tell();
virtual int Flush(); virtual int Flush();
void* GetData() { return data_; } void* GetData() { return data_; }
size_t GetDataSize() { return offset_; } size_t GetDataSize() { return offset_; }
std::string GetDataString(); std::string GetDataString();
protected: protected:
size_t Grow(size_t size); size_t Grow(size_t size);
protected: protected:
size_t grow_; size_t grow_;
void* data_; void* data_;
size_t datasize_; size_t datasize_;
size_t offset_; size_t offset_;
}; };
// Implementation of CefStreamReader for handlers. // Implementation of CefStreamReader for handlers.
class CefHandlerReader : public CefThreadSafeBase<CefStreamReader> class CefHandlerReader : public CefThreadSafeBase<CefStreamReader>
{ {
public: public:
CefHandlerReader(CefRefPtr<CefReadHandler> handler) : handler_(handler) {} CefHandlerReader(CefRefPtr<CefReadHandler> handler) : handler_(handler) {}
virtual size_t Read(void* ptr, size_t size, size_t n) virtual size_t Read(void* ptr, size_t size, size_t n)
{ {
return handler_->Read(ptr, size, n); return handler_->Read(ptr, size, n);
} }
virtual int Seek(long offset, int whence) virtual int Seek(long offset, int whence)
{ {
return handler_->Seek(offset, whence); return handler_->Seek(offset, whence);
} }
virtual long Tell() virtual long Tell()
{ {
return handler_->Tell(); return handler_->Tell();
} }
virtual int Eof() virtual int Eof()
{ {
return handler_->Eof(); return handler_->Eof();
} }
protected: protected:
CefRefPtr<CefReadHandler> handler_; CefRefPtr<CefReadHandler> handler_;
}; };
// Implementation of CefStreamWriter for handlers. // Implementation of CefStreamWriter for handlers.
class CefHandlerWriter : public CefThreadSafeBase<CefStreamWriter> class CefHandlerWriter : public CefThreadSafeBase<CefStreamWriter>
{ {
public: public:
CefHandlerWriter(CefRefPtr<CefWriteHandler> handler) : handler_(handler) {} CefHandlerWriter(CefRefPtr<CefWriteHandler> handler) : handler_(handler) {}
virtual size_t Write(const void* ptr, size_t size, size_t n) virtual size_t Write(const void* ptr, size_t size, size_t n)
{ {
return handler_->Write(ptr, size, n); return handler_->Write(ptr, size, n);
} }
virtual int Seek(long offset, int whence) virtual int Seek(long offset, int whence)
{ {
return handler_->Seek(offset, whence); return handler_->Seek(offset, whence);
} }
virtual long Tell() virtual long Tell()
{ {
return handler_->Tell(); return handler_->Tell();
} }
virtual int Flush() virtual int Flush()
{ {
return handler_->Flush(); return handler_->Flush();
} }
protected: protected:
CefRefPtr<CefWriteHandler> handler_; CefRefPtr<CefWriteHandler> handler_;
}; };
#endif // _STREAM_IMPL_H #endif // _STREAM_IMPL_H

View File

@ -1,136 +1,136 @@
// Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights // Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that // reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file. // can be found in the LICENSE file.
#ifndef _TRACKER_H #ifndef _TRACKER_H
#define _TRACKER_H #define _TRACKER_H
#include "include/cef.h" #include "include/cef.h"
// Class extended by objects that must be tracked. After creating a tracked // Class extended by objects that must be tracked. After creating a tracked
// object you should add it to the appropriate track manager. // object you should add it to the appropriate track manager.
class CefTrackObject class CefTrackObject
{ {
public: public:
CefTrackObject() CefTrackObject()
{ {
track_next_ = NULL; track_next_ = NULL;
track_prev_ = NULL; track_prev_ = NULL;
} }
virtual ~CefTrackObject() virtual ~CefTrackObject()
{ {
} }
// Returns true if the object is currently being tracked. // Returns true if the object is currently being tracked.
bool IsTracked() { return (track_prev_ || track_next_); } bool IsTracked() { return (track_prev_ || track_next_); }
private: private:
CefTrackObject* GetTrackPrev() { return track_prev_; } CefTrackObject* GetTrackPrev() { return track_prev_; }
void SetTrackPrev(CefTrackObject* base) { track_prev_ = base; } void SetTrackPrev(CefTrackObject* base) { track_prev_ = base; }
CefTrackObject* GetTrackNext() { return track_next_; } CefTrackObject* GetTrackNext() { return track_next_; }
void SetTrackNext(CefTrackObject* base) { track_next_ = base; } void SetTrackNext(CefTrackObject* base) { track_next_ = base; }
// Insert a new object into the tracking list before this object. // Insert a new object into the tracking list before this object.
void InsertTrackPrev(CefTrackObject* object) void InsertTrackPrev(CefTrackObject* object)
{ {
if(track_prev_) if(track_prev_)
track_prev_->SetTrackNext(object); track_prev_->SetTrackNext(object);
object->SetTrackNext(this); object->SetTrackNext(this);
object->SetTrackPrev(track_prev_); object->SetTrackPrev(track_prev_);
track_prev_ = object; track_prev_ = object;
} }
// Insert a new object into the tracking list after this object. // Insert a new object into the tracking list after this object.
void InsertTrackNext(CefTrackObject* object) void InsertTrackNext(CefTrackObject* object)
{ {
if(track_next_) if(track_next_)
track_next_->SetTrackPrev(object); track_next_->SetTrackPrev(object);
object->SetTrackPrev(this); object->SetTrackPrev(this);
object->SetTrackNext(track_next_); object->SetTrackNext(track_next_);
track_next_ = object; track_next_ = object;
} }
// Remove this object from the tracking list. // Remove this object from the tracking list.
void RemoveTracking() void RemoveTracking()
{ {
if(track_next_) if(track_next_)
track_next_->SetTrackPrev(track_prev_); track_next_->SetTrackPrev(track_prev_);
if(track_prev_) if(track_prev_)
track_prev_->SetTrackNext(track_next_); track_prev_->SetTrackNext(track_next_);
track_next_ = NULL; track_next_ = NULL;
track_prev_ = NULL; track_prev_ = NULL;
} }
private: private:
CefTrackObject* track_next_; CefTrackObject* track_next_;
CefTrackObject* track_prev_; CefTrackObject* track_prev_;
friend class CefTrackManager; friend class CefTrackManager;
}; };
// Class used to manage tracked objects. A single instance of this class // Class used to manage tracked objects. A single instance of this class
// should be created for each intended usage. Any objects that have not been // should be created for each intended usage. Any objects that have not been
// removed by explicit calls to the Destroy() method will be removed when the // removed by explicit calls to the Destroy() method will be removed when the
// manager object is destroyed. A manager object can be created as either a // manager object is destroyed. A manager object can be created as either a
// member variable of another class or by using lazy initialization: // member variable of another class or by using lazy initialization:
// base::LazyInstance<CefTrackManager> g_singleton(base::LINKER_INITIALIZED); // base::LazyInstance<CefTrackManager> g_singleton(base::LINKER_INITIALIZED);
class CefTrackManager : public CefThreadSafeBase<CefBase> class CefTrackManager : public CefThreadSafeBase<CefBase>
{ {
public: public:
CefTrackManager() : object_count_(0) {} CefTrackManager() : object_count_(0) {}
virtual ~CefTrackManager() virtual ~CefTrackManager()
{ {
DeleteAll(); DeleteAll();
} }
// Add an object to be tracked by this manager. // Add an object to be tracked by this manager.
void Add(CefTrackObject* object) void Add(CefTrackObject* object)
{ {
Lock(); Lock();
if(!object->IsTracked()) { if(!object->IsTracked()) {
tracker_.InsertTrackNext(object); tracker_.InsertTrackNext(object);
++object_count_; ++object_count_;
} }
Unlock(); Unlock();
} }
// Delete an object tracked by this manager. // Delete an object tracked by this manager.
bool Delete(CefTrackObject* object) bool Delete(CefTrackObject* object)
{ {
bool rv = false; bool rv = false;
Lock(); Lock();
if(object->IsTracked()) { if(object->IsTracked()) {
object->RemoveTracking(); object->RemoveTracking();
delete object; delete object;
--object_count_; --object_count_;
rv = true; rv = true;
} }
Unlock(); Unlock();
return rv; return rv;
} }
// Delete all objects tracked by this manager. // Delete all objects tracked by this manager.
void DeleteAll() void DeleteAll()
{ {
Lock(); Lock();
CefTrackObject* next; CefTrackObject* next;
do { do {
next = tracker_.GetTrackNext(); next = tracker_.GetTrackNext();
if(next) { if(next) {
next->RemoveTracking(); next->RemoveTracking();
delete next; delete next;
} }
} while(next != NULL); } while(next != NULL);
object_count_ = 0; object_count_ = 0;
Unlock(); Unlock();
} }
// Returns the number of objects currently being tracked. // Returns the number of objects currently being tracked.
long GetCount() { return object_count_; } long GetCount() { return object_count_; }
private: private:
CefTrackObject tracker_; CefTrackObject tracker_;
long object_count_; long object_count_;
}; };
#endif // _TRACKER_H #endif // _TRACKER_H

File diff suppressed because it is too large Load Diff

View File

@ -1,61 +1,61 @@
// Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights // Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that // reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file. // can be found in the LICENSE file.
#ifndef _V8_IMPL_H #ifndef _V8_IMPL_H
#define _V8_IMPL_H #define _V8_IMPL_H
#include "include/cef.h" #include "include/cef.h"
#include "v8/include/v8.h" #include "v8/include/v8.h"
class CefTrackObject; class CefTrackObject;
class CefV8ValueImpl : public CefThreadSafeBase<CefV8Value> class CefV8ValueImpl : public CefThreadSafeBase<CefV8Value>
{ {
public: public:
CefV8ValueImpl(); CefV8ValueImpl();
CefV8ValueImpl(v8::Handle<v8::Value> value, CefTrackObject* tracker = NULL); CefV8ValueImpl(v8::Handle<v8::Value> value, CefTrackObject* tracker = NULL);
virtual ~CefV8ValueImpl(); virtual ~CefV8ValueImpl();
bool Attach(v8::Handle<v8::Value> value, CefTrackObject* tracker = NULL); bool Attach(v8::Handle<v8::Value> value, CefTrackObject* tracker = NULL);
void Detach(); void Detach();
v8::Handle<v8::Value> GetValue(); v8::Handle<v8::Value> GetValue();
bool IsReservedKey(const std::wstring& key); bool IsReservedKey(const std::wstring& key);
virtual bool IsUndefined(); virtual bool IsUndefined();
virtual bool IsNull(); virtual bool IsNull();
virtual bool IsBool(); virtual bool IsBool();
virtual bool IsInt(); virtual bool IsInt();
virtual bool IsDouble(); virtual bool IsDouble();
virtual bool IsString(); virtual bool IsString();
virtual bool IsObject(); virtual bool IsObject();
virtual bool IsArray(); virtual bool IsArray();
virtual bool IsFunction(); virtual bool IsFunction();
virtual bool GetBoolValue(); virtual bool GetBoolValue();
virtual int GetIntValue(); virtual int GetIntValue();
virtual double GetDoubleValue(); virtual double GetDoubleValue();
virtual std::wstring GetStringValue(); virtual std::wstring GetStringValue();
virtual bool HasValue(const std::wstring& key); virtual bool HasValue(const std::wstring& key);
virtual bool HasValue(int index); virtual bool HasValue(int index);
virtual bool DeleteValue(const std::wstring& key); virtual bool DeleteValue(const std::wstring& key);
virtual bool DeleteValue(int index); virtual bool DeleteValue(int index);
virtual CefRefPtr<CefV8Value> GetValue(const std::wstring& key); virtual CefRefPtr<CefV8Value> GetValue(const std::wstring& key);
virtual CefRefPtr<CefV8Value> GetValue(int index); virtual CefRefPtr<CefV8Value> GetValue(int index);
virtual bool SetValue(const std::wstring& key, CefRefPtr<CefV8Value> value); virtual bool SetValue(const std::wstring& key, CefRefPtr<CefV8Value> value);
virtual bool SetValue(int index, CefRefPtr<CefV8Value> value); virtual bool SetValue(int index, CefRefPtr<CefV8Value> value);
virtual bool GetKeys(std::vector<std::wstring>& keys); virtual bool GetKeys(std::vector<std::wstring>& keys);
virtual CefRefPtr<CefBase> GetUserData(); virtual CefRefPtr<CefBase> GetUserData();
virtual int GetArrayLength(); virtual int GetArrayLength();
virtual std::wstring GetFunctionName(); virtual std::wstring GetFunctionName();
virtual CefRefPtr<CefV8Handler> GetFunctionHandler(); virtual CefRefPtr<CefV8Handler> GetFunctionHandler();
virtual bool ExecuteFunction(CefRefPtr<CefV8Value> object, virtual bool ExecuteFunction(CefRefPtr<CefV8Value> object,
const CefV8ValueList& arguments, const CefV8ValueList& arguments,
CefRefPtr<CefV8Value>& retval, CefRefPtr<CefV8Value>& retval,
std::wstring& exception); std::wstring& exception);
protected: protected:
v8::Persistent<v8::Value> v8_value_; v8::Persistent<v8::Value> v8_value_;
CefTrackObject* tracker_; CefTrackObject* tracker_;
}; };
#endif //_V8_IMPL_H #endif //_V8_IMPL_H

View File

@ -1,54 +1,54 @@
// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "webview_host.h" #include "webview_host.h"
#include "browser_webview_delegate.h" #include "browser_webview_delegate.h"
#include "gfx/rect.h" #include "gfx/rect.h"
#include "gfx/size.h" #include "gfx/size.h"
#include "base/win_util.h" #include "base/win_util.h"
#include "third_party/WebKit/WebKit/chromium/public/WebView.h" #include "third_party/WebKit/WebKit/chromium/public/WebView.h"
#include "webkit/glue/webpreferences.h" #include "webkit/glue/webpreferences.h"
using namespace WebKit; using namespace WebKit;
static const wchar_t kWindowClassName[] = L"WebViewHost"; static const wchar_t kWindowClassName[] = L"WebViewHost";
/*static*/ /*static*/
WebViewHost* WebViewHost::Create(HWND parent_view, WebViewHost* WebViewHost::Create(HWND parent_view,
BrowserWebViewDelegate* delegate, BrowserWebViewDelegate* delegate,
WebDevToolsAgentClient* dev_tools_client, WebDevToolsAgentClient* dev_tools_client,
const WebPreferences& prefs) { const WebPreferences& prefs) {
WebViewHost* host = new WebViewHost(); WebViewHost* host = new WebViewHost();
static bool registered_class = false; static bool registered_class = false;
if (!registered_class) { if (!registered_class) {
WNDCLASSEX wcex = {0}; WNDCLASSEX wcex = {0};
wcex.cbSize = sizeof(wcex); wcex.cbSize = sizeof(wcex);
wcex.style = CS_DBLCLKS; wcex.style = CS_DBLCLKS;
wcex.lpfnWndProc = WebWidgetHost::WndProc; wcex.lpfnWndProc = WebWidgetHost::WndProc;
wcex.hInstance = GetModuleHandle(NULL); wcex.hInstance = GetModuleHandle(NULL);
wcex.hCursor = LoadCursor(NULL, IDC_ARROW); wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
wcex.lpszClassName = kWindowClassName; wcex.lpszClassName = kWindowClassName;
RegisterClassEx(&wcex); RegisterClassEx(&wcex);
registered_class = true; registered_class = true;
} }
host->view_ = CreateWindow(kWindowClassName, NULL, host->view_ = CreateWindow(kWindowClassName, NULL,
WS_CHILD|WS_CLIPCHILDREN|WS_CLIPSIBLINGS, 0, 0, WS_CHILD|WS_CLIPCHILDREN|WS_CLIPSIBLINGS, 0, 0,
0, 0, parent_view, NULL, 0, 0, parent_view, NULL,
GetModuleHandle(NULL), NULL); GetModuleHandle(NULL), NULL);
win_util::SetWindowUserData(host->view_, host); win_util::SetWindowUserData(host->view_, host);
host->webwidget_ = WebView::create(delegate, dev_tools_client); host->webwidget_ = WebView::create(delegate, dev_tools_client);
prefs.Apply(host->webview()); prefs.Apply(host->webview());
host->webview()->initializeMainFrame(delegate); host->webview()->initializeMainFrame(delegate);
return host; return host;
} }
WebView* WebViewHost::webview() const { WebView* WebViewHost::webview() const {
return static_cast<WebView*>(webwidget_); return static_cast<WebView*>(webwidget_);
} }

View File

@ -1,42 +1,42 @@
// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef _WEBVIEW_HOST_H #ifndef _WEBVIEW_HOST_H
#define _WEBVIEW_HOST_H #define _WEBVIEW_HOST_H
#include "base/basictypes.h" #include "base/basictypes.h"
#include "gfx/rect.h" #include "gfx/rect.h"
#include "gfx/native_widget_types.h" #include "gfx/native_widget_types.h"
#include "webwidget_host.h" #include "webwidget_host.h"
struct WebPreferences; struct WebPreferences;
class BrowserWebViewDelegate; class BrowserWebViewDelegate;
namespace WebKit { namespace WebKit {
class WebDevToolsAgentClient; class WebDevToolsAgentClient;
class WebView; class WebView;
} }
// This class is a simple ViewHandle-based host for a WebView // This class is a simple ViewHandle-based host for a WebView
class WebViewHost : public WebWidgetHost { class WebViewHost : public WebWidgetHost {
public: public:
// The new instance is deleted once the associated ViewHandle is destroyed. // The new instance is deleted once the associated ViewHandle is destroyed.
// The newly created window should be resized after it is created, using the // The newly created window should be resized after it is created, using the
// MoveWindow (or equivalent) function. // MoveWindow (or equivalent) function.
static WebViewHost* Create(gfx::NativeView parent_window, static WebViewHost* Create(gfx::NativeView parent_window,
BrowserWebViewDelegate* delegate, BrowserWebViewDelegate* delegate,
WebKit::WebDevToolsAgentClient* devtools_client, WebKit::WebDevToolsAgentClient* devtools_client,
const WebPreferences& prefs); const WebPreferences& prefs);
WebKit::WebView* webview() const; WebKit::WebView* webview() const;
protected: protected:
#if defined(OS_WIN) #if defined(OS_WIN)
virtual bool WndProc(UINT message, WPARAM wparam, LPARAM lparam) { virtual bool WndProc(UINT message, WPARAM wparam, LPARAM lparam) {
return false; return false;
} }
#endif #endif
}; };
#endif // _WEBVIEW_HOST_H #endif // _WEBVIEW_HOST_H

View File

@ -1,457 +1,457 @@
// Copyright (c) 2008-2009 The Chromium Embedded Framework Authors. // Copyright (c) 2008-2009 The Chromium Embedded Framework Authors.
// Portions copyright (c) 2006-2008 The Chromium Authors. All rights reserved. // Portions copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "webwidget_host.h" #include "webwidget_host.h"
#include "gfx/rect.h" #include "gfx/rect.h"
#include "base/logging.h" #include "base/logging.h"
#include "base/win_util.h" #include "base/win_util.h"
#include "third_party/WebKit/WebKit/chromium/public/WebInputEvent.h" #include "third_party/WebKit/WebKit/chromium/public/WebInputEvent.h"
#include "third_party/WebKit/WebKit/chromium/public/WebPopupMenu.h" #include "third_party/WebKit/WebKit/chromium/public/WebPopupMenu.h"
#include "third_party/WebKit/WebKit/chromium/public/WebScreenInfo.h" #include "third_party/WebKit/WebKit/chromium/public/WebScreenInfo.h"
#include "third_party/WebKit/WebKit/chromium/public/WebSize.h" #include "third_party/WebKit/WebKit/chromium/public/WebSize.h"
#include "third_party/WebKit/WebKit/chromium/public/win/WebInputEventFactory.h" #include "third_party/WebKit/WebKit/chromium/public/win/WebInputEventFactory.h"
#include "third_party/WebKit/WebKit/chromium/public/win/WebScreenInfoFactory.h" #include "third_party/WebKit/WebKit/chromium/public/win/WebScreenInfoFactory.h"
#include <commctrl.h> #include <commctrl.h>
using WebKit::WebInputEvent; using WebKit::WebInputEvent;
using WebKit::WebInputEventFactory; using WebKit::WebInputEventFactory;
using WebKit::WebKeyboardEvent; using WebKit::WebKeyboardEvent;
using WebKit::WebMouseEvent; using WebKit::WebMouseEvent;
using WebKit::WebMouseWheelEvent; using WebKit::WebMouseWheelEvent;
using WebKit::WebPopupMenu; using WebKit::WebPopupMenu;
using WebKit::WebScreenInfo; using WebKit::WebScreenInfo;
using WebKit::WebScreenInfoFactory; using WebKit::WebScreenInfoFactory;
using WebKit::WebSize; using WebKit::WebSize;
using WebKit::WebWidget; using WebKit::WebWidget;
using WebKit::WebWidgetClient; using WebKit::WebWidgetClient;
static const wchar_t kWindowClassName[] = L"WebWidgetHost"; static const wchar_t kWindowClassName[] = L"WebWidgetHost";
/*static*/ /*static*/
WebWidgetHost* WebWidgetHost::Create(HWND parent_view, WebWidgetHost* WebWidgetHost::Create(HWND parent_view,
WebWidgetClient* client) { WebWidgetClient* client) {
WebWidgetHost* host = new WebWidgetHost(); WebWidgetHost* host = new WebWidgetHost();
static bool registered_class = false; static bool registered_class = false;
if (!registered_class) { if (!registered_class) {
WNDCLASSEX wcex = {0}; WNDCLASSEX wcex = {0};
wcex.cbSize = sizeof(wcex); wcex.cbSize = sizeof(wcex);
wcex.style = CS_DBLCLKS; wcex.style = CS_DBLCLKS;
wcex.lpfnWndProc = WebWidgetHost::WndProc; wcex.lpfnWndProc = WebWidgetHost::WndProc;
wcex.hInstance = GetModuleHandle(NULL); wcex.hInstance = GetModuleHandle(NULL);
wcex.hCursor = LoadCursor(NULL, IDC_ARROW); wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
wcex.lpszClassName = kWindowClassName; wcex.lpszClassName = kWindowClassName;
RegisterClassEx(&wcex); RegisterClassEx(&wcex);
registered_class = true; registered_class = true;
} }
host->view_ = CreateWindowEx(WS_EX_TOOLWINDOW, host->view_ = CreateWindowEx(WS_EX_TOOLWINDOW,
kWindowClassName, kWindowClassName, WS_POPUP, kWindowClassName, kWindowClassName, WS_POPUP,
0, 0, 0, 0, 0, 0, 0, 0,
parent_view, NULL, GetModuleHandle(NULL), NULL); parent_view, NULL, GetModuleHandle(NULL), NULL);
win_util::SetWindowUserData(host->view_, host); win_util::SetWindowUserData(host->view_, host);
host->webwidget_ = WebPopupMenu::create(client); host->webwidget_ = WebPopupMenu::create(client);
return host; return host;
} }
/*static*/ /*static*/
static WebWidgetHost* FromWindow(HWND view) { static WebWidgetHost* FromWindow(HWND view) {
return reinterpret_cast<WebWidgetHost*>(win_util::GetWindowUserData(view)); return reinterpret_cast<WebWidgetHost*>(win_util::GetWindowUserData(view));
} }
/*static*/ /*static*/
LRESULT CALLBACK WebWidgetHost::WndProc(HWND hwnd, UINT message, WPARAM wparam, LRESULT CALLBACK WebWidgetHost::WndProc(HWND hwnd, UINT message, WPARAM wparam,
LPARAM lparam) { LPARAM lparam) {
WebWidgetHost* host = FromWindow(hwnd); WebWidgetHost* host = FromWindow(hwnd);
if (host && !host->WndProc(message, wparam, lparam)) { if (host && !host->WndProc(message, wparam, lparam)) {
switch (message) { switch (message) {
case WM_PAINT: { case WM_PAINT: {
RECT rect; RECT rect;
if (GetUpdateRect(hwnd, &rect, FALSE)) { if (GetUpdateRect(hwnd, &rect, FALSE)) {
host->UpdatePaintRect(gfx::Rect(rect)); host->UpdatePaintRect(gfx::Rect(rect));
} }
host->Paint(); host->Paint();
return 0; return 0;
} }
case WM_ERASEBKGND: case WM_ERASEBKGND:
// Do nothing here to avoid flashing, the background will be erased // Do nothing here to avoid flashing, the background will be erased
// during painting. // during painting.
return 0; return 0;
case WM_SIZE: case WM_SIZE:
host->Resize(lparam); host->Resize(lparam);
return 0; return 0;
case WM_MOUSEMOVE: case WM_MOUSEMOVE:
case WM_MOUSELEAVE: case WM_MOUSELEAVE:
case WM_LBUTTONDOWN: case WM_LBUTTONDOWN:
case WM_MBUTTONDOWN: case WM_MBUTTONDOWN:
case WM_RBUTTONDOWN: case WM_RBUTTONDOWN:
case WM_LBUTTONUP: case WM_LBUTTONUP:
case WM_MBUTTONUP: case WM_MBUTTONUP:
case WM_RBUTTONUP: case WM_RBUTTONUP:
case WM_LBUTTONDBLCLK: case WM_LBUTTONDBLCLK:
case WM_MBUTTONDBLCLK: case WM_MBUTTONDBLCLK:
case WM_RBUTTONDBLCLK: case WM_RBUTTONDBLCLK:
host->MouseEvent(message, wparam, lparam); host->MouseEvent(message, wparam, lparam);
break; break;
case WM_MOUSEWHEEL: case WM_MOUSEWHEEL:
host->WheelEvent(wparam, lparam); host->WheelEvent(wparam, lparam);
break; break;
case WM_CAPTURECHANGED: case WM_CAPTURECHANGED:
case WM_CANCELMODE: case WM_CANCELMODE:
host->CaptureLostEvent(); host->CaptureLostEvent();
break; break;
// TODO(darin): add WM_SYSKEY{DOWN/UP} to capture ALT key actions // TODO(darin): add WM_SYSKEY{DOWN/UP} to capture ALT key actions
case WM_KEYDOWN: case WM_KEYDOWN:
case WM_KEYUP: case WM_KEYUP:
case WM_SYSKEYDOWN: case WM_SYSKEYDOWN:
case WM_SYSKEYUP: case WM_SYSKEYUP:
case WM_CHAR: case WM_CHAR:
case WM_SYSCHAR: case WM_SYSCHAR:
host->KeyEvent(message, wparam, lparam); host->KeyEvent(message, wparam, lparam);
break; break;
case WM_SETFOCUS: case WM_SETFOCUS:
host->SetFocus(true); host->SetFocus(true);
break; break;
case WM_KILLFOCUS: case WM_KILLFOCUS:
host->SetFocus(false); host->SetFocus(false);
break; break;
case WM_NOTIFY: case WM_NOTIFY:
host->OnNotify(0, (NMHDR*)lparam); host->OnNotify(0, (NMHDR*)lparam);
break; break;
} }
} }
return DefWindowProc(hwnd, message, wparam, lparam);; return DefWindowProc(hwnd, message, wparam, lparam);;
} }
void WebWidgetHost::DidInvalidateRect(const gfx::Rect& damaged_rect) { void WebWidgetHost::DidInvalidateRect(const gfx::Rect& damaged_rect) {
DLOG_IF(WARNING, painting_) << "unexpected invalidation while painting"; DLOG_IF(WARNING, painting_) << "unexpected invalidation while painting";
// If this invalidate overlaps with a pending scroll, then we have to // If this invalidate overlaps with a pending scroll, then we have to
// downgrade to invalidating the scroll rect. // downgrade to invalidating the scroll rect.
if (damaged_rect.Intersects(scroll_rect_)) { if (damaged_rect.Intersects(scroll_rect_)) {
paint_rect_ = paint_rect_.Union(scroll_rect_); paint_rect_ = paint_rect_.Union(scroll_rect_);
ResetScrollRect(); ResetScrollRect();
} }
paint_rect_ = paint_rect_.Union(damaged_rect); paint_rect_ = paint_rect_.Union(damaged_rect);
RECT r = damaged_rect.ToRECT(); RECT r = damaged_rect.ToRECT();
InvalidateRect(view_, &r, FALSE); InvalidateRect(view_, &r, FALSE);
} }
void WebWidgetHost::DidScrollRect(int dx, int dy, const gfx::Rect& clip_rect) { void WebWidgetHost::DidScrollRect(int dx, int dy, const gfx::Rect& clip_rect) {
if (dx != 0 && dy != 0) { if (dx != 0 && dy != 0) {
// We only support uni-directional scroll // We only support uni-directional scroll
DidScrollRect(0, dy, clip_rect); DidScrollRect(0, dy, clip_rect);
dy = 0; dy = 0;
} }
// If we already have a pending scroll operation or if this scroll operation // If we already have a pending scroll operation or if this scroll operation
// intersects the existing paint region, then just failover to invalidating. // intersects the existing paint region, then just failover to invalidating.
if (!scroll_rect_.IsEmpty() || paint_rect_.Intersects(clip_rect)) { if (!scroll_rect_.IsEmpty() || paint_rect_.Intersects(clip_rect)) {
paint_rect_ = paint_rect_.Union(scroll_rect_); paint_rect_ = paint_rect_.Union(scroll_rect_);
ResetScrollRect(); ResetScrollRect();
paint_rect_ = paint_rect_.Union(clip_rect); paint_rect_ = paint_rect_.Union(clip_rect);
} }
// We will perform scrolling lazily, when requested to actually paint. // We will perform scrolling lazily, when requested to actually paint.
scroll_rect_ = clip_rect; scroll_rect_ = clip_rect;
scroll_dx_ = dx; scroll_dx_ = dx;
scroll_dy_ = dy; scroll_dy_ = dy;
RECT r = clip_rect.ToRECT(); RECT r = clip_rect.ToRECT();
InvalidateRect(view_, &r, FALSE); InvalidateRect(view_, &r, FALSE);
} }
void WebWidgetHost::ScheduleComposite() { void WebWidgetHost::ScheduleComposite() {
if (!webwidget_) if (!webwidget_)
return; return;
WebSize size = webwidget_->size(); WebSize size = webwidget_->size();
gfx::Rect rect(0, 0, size.width, size.height); gfx::Rect rect(0, 0, size.width, size.height);
RECT r = rect.ToRECT(); RECT r = rect.ToRECT();
InvalidateRect(view_, &r, FALSE); InvalidateRect(view_, &r, FALSE);
} }
void WebWidgetHost::SetCursor(HCURSOR cursor) { void WebWidgetHost::SetCursor(HCURSOR cursor) {
SetClassLong(view_, GCL_HCURSOR, SetClassLong(view_, GCL_HCURSOR,
static_cast<LONG>(reinterpret_cast<LONG_PTR>(cursor))); static_cast<LONG>(reinterpret_cast<LONG_PTR>(cursor)));
::SetCursor(cursor); ::SetCursor(cursor);
} }
void WebWidgetHost::DiscardBackingStore() { void WebWidgetHost::DiscardBackingStore() {
canvas_.reset(); canvas_.reset();
} }
WebWidgetHost::WebWidgetHost() WebWidgetHost::WebWidgetHost()
: view_(NULL), : view_(NULL),
webwidget_(NULL), webwidget_(NULL),
track_mouse_leave_(false), track_mouse_leave_(false),
scroll_dx_(0), scroll_dx_(0),
scroll_dy_(0), scroll_dy_(0),
tooltip_view_(NULL), tooltip_view_(NULL),
tooltip_showing_(false) { tooltip_showing_(false) {
set_painting(false); set_painting(false);
} }
WebWidgetHost::~WebWidgetHost() { WebWidgetHost::~WebWidgetHost() {
win_util::SetWindowUserData(view_, 0); win_util::SetWindowUserData(view_, 0);
TrackMouseLeave(false); TrackMouseLeave(false);
ResetTooltip(); ResetTooltip();
} }
bool WebWidgetHost::WndProc(UINT message, WPARAM wparam, LPARAM lparam) { bool WebWidgetHost::WndProc(UINT message, WPARAM wparam, LPARAM lparam) {
switch (message) { switch (message) {
case WM_ACTIVATE: case WM_ACTIVATE:
if (wparam == WA_INACTIVE) { if (wparam == WA_INACTIVE) {
PostMessage(view_, WM_CLOSE, 0, 0); PostMessage(view_, WM_CLOSE, 0, 0);
return true; return true;
} }
break; break;
} }
return false; return false;
} }
void WebWidgetHost::UpdatePaintRect(const gfx::Rect& rect) { void WebWidgetHost::UpdatePaintRect(const gfx::Rect& rect) {
paint_rect_ = paint_rect_.Union(rect); paint_rect_ = paint_rect_.Union(rect);
} }
void WebWidgetHost::Paint() { void WebWidgetHost::Paint() {
RECT r; RECT r;
GetClientRect(view_, &r); GetClientRect(view_, &r);
gfx::Rect client_rect(r); gfx::Rect client_rect(r);
// Allocate a canvas if necessary // Allocate a canvas if necessary
if (!canvas_.get()) { if (!canvas_.get()) {
ResetScrollRect(); ResetScrollRect();
paint_rect_ = client_rect; paint_rect_ = client_rect;
canvas_.reset(new skia::PlatformCanvas( canvas_.reset(new skia::PlatformCanvas(
paint_rect_.width(), paint_rect_.height(), true)); paint_rect_.width(), paint_rect_.height(), true));
} }
// This may result in more invalidation // This may result in more invalidation
webwidget_->layout(); webwidget_->layout();
// Scroll the canvas if necessary // Scroll the canvas if necessary
scroll_rect_ = client_rect.Intersect(scroll_rect_); scroll_rect_ = client_rect.Intersect(scroll_rect_);
if (!scroll_rect_.IsEmpty()) { if (!scroll_rect_.IsEmpty()) {
HDC hdc = canvas_->getTopPlatformDevice().getBitmapDC(); HDC hdc = canvas_->getTopPlatformDevice().getBitmapDC();
RECT damaged_rect, r = scroll_rect_.ToRECT(); RECT damaged_rect, r = scroll_rect_.ToRECT();
ScrollDC(hdc, scroll_dx_, scroll_dy_, NULL, &r, NULL, &damaged_rect); ScrollDC(hdc, scroll_dx_, scroll_dy_, NULL, &r, NULL, &damaged_rect);
PaintRect(gfx::Rect(damaged_rect)); PaintRect(gfx::Rect(damaged_rect));
} }
ResetScrollRect(); ResetScrollRect();
// Paint the canvas if necessary. Allow painting to generate extra rects the // Paint the canvas if necessary. Allow painting to generate extra rects the
// first time we call it. This is necessary because some WebCore rendering // first time we call it. This is necessary because some WebCore rendering
// objects update their layout only when painted. // objects update their layout only when painted.
for (int i = 0; i < 2; ++i) { for (int i = 0; i < 2; ++i) {
paint_rect_ = client_rect.Intersect(paint_rect_); paint_rect_ = client_rect.Intersect(paint_rect_);
if (!paint_rect_.IsEmpty()) { if (!paint_rect_.IsEmpty()) {
gfx::Rect rect(paint_rect_); gfx::Rect rect(paint_rect_);
paint_rect_ = gfx::Rect(); paint_rect_ = gfx::Rect();
DLOG_IF(WARNING, i == 1) << "painting caused additional invalidations"; DLOG_IF(WARNING, i == 1) << "painting caused additional invalidations";
PaintRect(rect); PaintRect(rect);
} }
} }
DCHECK(paint_rect_.IsEmpty()); DCHECK(paint_rect_.IsEmpty());
// Paint to the screen // Paint to the screen
PAINTSTRUCT ps; PAINTSTRUCT ps;
BeginPaint(view_, &ps); BeginPaint(view_, &ps);
canvas_->getTopPlatformDevice().drawToHDC(ps.hdc, canvas_->getTopPlatformDevice().drawToHDC(ps.hdc,
ps.rcPaint.left, ps.rcPaint.left,
ps.rcPaint.top, ps.rcPaint.top,
&ps.rcPaint); &ps.rcPaint);
EndPaint(view_, &ps); EndPaint(view_, &ps);
// Draw children // Draw children
UpdateWindow(view_); UpdateWindow(view_);
} }
WebScreenInfo WebWidgetHost::GetScreenInfo() { WebScreenInfo WebWidgetHost::GetScreenInfo() {
return WebScreenInfoFactory::screenInfo(view_); return WebScreenInfoFactory::screenInfo(view_);
} }
void WebWidgetHost::Resize(LPARAM lparam) { void WebWidgetHost::Resize(LPARAM lparam) {
// Force an entire re-paint. TODO(darin): Maybe reuse this memory buffer. // Force an entire re-paint. TODO(darin): Maybe reuse this memory buffer.
DiscardBackingStore(); DiscardBackingStore();
webwidget_->resize(WebSize(LOWORD(lparam), HIWORD(lparam))); webwidget_->resize(WebSize(LOWORD(lparam), HIWORD(lparam)));
EnsureTooltip(); EnsureTooltip();
} }
void WebWidgetHost::MouseEvent(UINT message, WPARAM wparam, LPARAM lparam) { void WebWidgetHost::MouseEvent(UINT message, WPARAM wparam, LPARAM lparam) {
const WebMouseEvent& event = WebInputEventFactory::mouseEvent( const WebMouseEvent& event = WebInputEventFactory::mouseEvent(
view_, message, wparam, lparam); view_, message, wparam, lparam);
switch (event.type) { switch (event.type) {
case WebInputEvent::MouseMove: case WebInputEvent::MouseMove:
TrackMouseLeave(true); TrackMouseLeave(true);
break; break;
case WebInputEvent::MouseLeave: case WebInputEvent::MouseLeave:
TrackMouseLeave(false); TrackMouseLeave(false);
break; break;
case WebInputEvent::MouseDown: case WebInputEvent::MouseDown:
SetCapture(view_); SetCapture(view_);
// This mimics a temporary workaround in RenderWidgetHostViewWin // This mimics a temporary workaround in RenderWidgetHostViewWin
// for bug 765011 to get focus when the mouse is clicked. This // for bug 765011 to get focus when the mouse is clicked. This
// happens after the mouse down event is sent to the renderer // happens after the mouse down event is sent to the renderer
// because normally Windows does a WM_SETFOCUS after WM_LBUTTONDOWN. // because normally Windows does a WM_SETFOCUS after WM_LBUTTONDOWN.
::SetFocus(view_); ::SetFocus(view_);
break; break;
case WebInputEvent::MouseUp: case WebInputEvent::MouseUp:
if (GetCapture() == view_) if (GetCapture() == view_)
ReleaseCapture(); ReleaseCapture();
break; break;
} }
webwidget_->handleInputEvent(event); webwidget_->handleInputEvent(event);
} }
void WebWidgetHost::WheelEvent(WPARAM wparam, LPARAM lparam) { void WebWidgetHost::WheelEvent(WPARAM wparam, LPARAM lparam) {
const WebMouseWheelEvent& event = WebInputEventFactory::mouseWheelEvent( const WebMouseWheelEvent& event = WebInputEventFactory::mouseWheelEvent(
view_, WM_MOUSEWHEEL, wparam, lparam); view_, WM_MOUSEWHEEL, wparam, lparam);
webwidget_->handleInputEvent(event); webwidget_->handleInputEvent(event);
} }
void WebWidgetHost::KeyEvent(UINT message, WPARAM wparam, LPARAM lparam) { void WebWidgetHost::KeyEvent(UINT message, WPARAM wparam, LPARAM lparam) {
const WebKeyboardEvent& event = WebInputEventFactory::keyboardEvent( const WebKeyboardEvent& event = WebInputEventFactory::keyboardEvent(
view_, message, wparam, lparam); view_, message, wparam, lparam);
last_key_event_ = event; last_key_event_ = event;
webwidget_->handleInputEvent(event); webwidget_->handleInputEvent(event);
} }
void WebWidgetHost::CaptureLostEvent() { void WebWidgetHost::CaptureLostEvent() {
webwidget_->mouseCaptureLost(); webwidget_->mouseCaptureLost();
} }
void WebWidgetHost::SetFocus(bool enable) { void WebWidgetHost::SetFocus(bool enable) {
webwidget_->setFocus(enable); webwidget_->setFocus(enable);
} }
void WebWidgetHost::OnNotify(WPARAM wparam, NMHDR* header) { void WebWidgetHost::OnNotify(WPARAM wparam, NMHDR* header) {
if (tooltip_view_ == NULL) if (tooltip_view_ == NULL)
return; return;
switch (header->code) { switch (header->code) {
case TTN_GETDISPINFO: case TTN_GETDISPINFO:
{ {
NMTTDISPINFOW* tooltip_info = reinterpret_cast<NMTTDISPINFOW*>(header); NMTTDISPINFOW* tooltip_info = reinterpret_cast<NMTTDISPINFOW*>(header);
tooltip_info->szText[0] = L'\0'; tooltip_info->szText[0] = L'\0';
tooltip_info->lpszText = const_cast<wchar_t*>(tooltip_text_.c_str()); tooltip_info->lpszText = const_cast<wchar_t*>(tooltip_text_.c_str());
::SendMessage(tooltip_view_, TTM_SETMAXTIPWIDTH, 0, 1024); ::SendMessage(tooltip_view_, TTM_SETMAXTIPWIDTH, 0, 1024);
} }
break; break;
case TTN_POP: case TTN_POP:
tooltip_showing_ = false; tooltip_showing_ = false;
break; break;
case TTN_SHOW: case TTN_SHOW:
tooltip_showing_ = true; tooltip_showing_ = true;
break; break;
} }
} }
void WebWidgetHost::SetTooltipText(const std::wstring& new_tooltip_text) { void WebWidgetHost::SetTooltipText(const std::wstring& new_tooltip_text) {
if (new_tooltip_text != tooltip_text_) { if (new_tooltip_text != tooltip_text_) {
tooltip_text_ = new_tooltip_text; tooltip_text_ = new_tooltip_text;
// Need to check if the tooltip is already showing so that we don't // Need to check if the tooltip is already showing so that we don't
// immediately show the tooltip with no delay when we move the mouse from // immediately show the tooltip with no delay when we move the mouse from
// a region with no tooltip to a region with a tooltip. // a region with no tooltip to a region with a tooltip.
if (::IsWindow(tooltip_view_) && tooltip_showing_) { if (::IsWindow(tooltip_view_) && tooltip_showing_) {
::SendMessage(tooltip_view_, TTM_POP, 0, 0); ::SendMessage(tooltip_view_, TTM_POP, 0, 0);
::SendMessage(tooltip_view_, TTM_POPUP, 0, 0); ::SendMessage(tooltip_view_, TTM_POPUP, 0, 0);
} }
} }
else { else {
// Make sure the tooltip gets closed after TTN_POP gets sent. For some // Make sure the tooltip gets closed after TTN_POP gets sent. For some
// reason this doesn't happen automatically, so moving the mouse around // reason this doesn't happen automatically, so moving the mouse around
// within the same link/image/etc doesn't cause the tooltip to re-appear. // within the same link/image/etc doesn't cause the tooltip to re-appear.
if (!tooltip_showing_) { if (!tooltip_showing_) {
if (::IsWindow(tooltip_view_)) if (::IsWindow(tooltip_view_))
::SendMessage(tooltip_view_, TTM_POP, 0, 0); ::SendMessage(tooltip_view_, TTM_POP, 0, 0);
} }
} }
} }
void WebWidgetHost::EnsureTooltip() { void WebWidgetHost::EnsureTooltip() {
UINT message = TTM_NEWTOOLRECT; UINT message = TTM_NEWTOOLRECT;
TOOLINFO ti; TOOLINFO ti;
ti.cbSize = sizeof(ti); ti.cbSize = sizeof(ti);
ti.hwnd = view_handle(); ti.hwnd = view_handle();
ti.uId = 0; ti.uId = 0;
if (!::IsWindow(tooltip_view_)) { if (!::IsWindow(tooltip_view_)) {
message = TTM_ADDTOOL; message = TTM_ADDTOOL;
tooltip_view_ = CreateWindowEx( tooltip_view_ = CreateWindowEx(
WS_EX_TRANSPARENT, WS_EX_TRANSPARENT,
TOOLTIPS_CLASS, L"tooltip_view_", TTS_NOPREFIX, 0, 0, 0, 0, view_handle(), NULL, TOOLTIPS_CLASS, L"tooltip_view_", TTS_NOPREFIX, 0, 0, 0, 0, view_handle(), NULL,
NULL, NULL); NULL, NULL);
ti.uFlags = TTF_SUBCLASS; ti.uFlags = TTF_SUBCLASS;
ti.lpszText = LPSTR_TEXTCALLBACK; ti.lpszText = LPSTR_TEXTCALLBACK;
} }
GetClientRect(view_handle(), &ti.rect); GetClientRect(view_handle(), &ti.rect);
SendMessage(tooltip_view_, message, NULL, reinterpret_cast<LPARAM>(&ti)); SendMessage(tooltip_view_, message, NULL, reinterpret_cast<LPARAM>(&ti));
} }
void WebWidgetHost::ResetTooltip() { void WebWidgetHost::ResetTooltip() {
if (::IsWindow(tooltip_view_)) if (::IsWindow(tooltip_view_))
::DestroyWindow(tooltip_view_); ::DestroyWindow(tooltip_view_);
tooltip_view_ = NULL; tooltip_view_ = NULL;
} }
void WebWidgetHost::TrackMouseLeave(bool track) { void WebWidgetHost::TrackMouseLeave(bool track) {
if (track == track_mouse_leave_) if (track == track_mouse_leave_)
return; return;
track_mouse_leave_ = track; track_mouse_leave_ = track;
DCHECK(view_); DCHECK(view_);
TRACKMOUSEEVENT tme; TRACKMOUSEEVENT tme;
tme.cbSize = sizeof(TRACKMOUSEEVENT); tme.cbSize = sizeof(TRACKMOUSEEVENT);
tme.dwFlags = TME_LEAVE; tme.dwFlags = TME_LEAVE;
if (!track_mouse_leave_) if (!track_mouse_leave_)
tme.dwFlags |= TME_CANCEL; tme.dwFlags |= TME_CANCEL;
tme.hwndTrack = view_; tme.hwndTrack = view_;
TrackMouseEvent(&tme); TrackMouseEvent(&tme);
} }
void WebWidgetHost::ResetScrollRect() { void WebWidgetHost::ResetScrollRect() {
scroll_rect_ = gfx::Rect(); scroll_rect_ = gfx::Rect();
scroll_dx_ = 0; scroll_dx_ = 0;
scroll_dy_ = 0; scroll_dy_ = 0;
} }
void WebWidgetHost::PaintRect(const gfx::Rect& rect) { void WebWidgetHost::PaintRect(const gfx::Rect& rect) {
#ifndef NDEBUG #ifndef NDEBUG
DCHECK(!painting_); DCHECK(!painting_);
#endif #endif
DCHECK(canvas_.get()); DCHECK(canvas_.get());
set_painting(true); set_painting(true);
webwidget_->paint(canvas_.get(), rect); webwidget_->paint(canvas_.get(), rect);
set_painting(false); set_painting(false);
} }

View File

@ -1,144 +1,144 @@
// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef _WEBWIDGET_HOST_H #ifndef _WEBWIDGET_HOST_H
#define _WEBWIDGET_HOST_H #define _WEBWIDGET_HOST_H
#include "base/basictypes.h" #include "base/basictypes.h"
#include "gfx/rect.h" #include "gfx/rect.h"
#include "base/scoped_ptr.h" #include "base/scoped_ptr.h"
#include "gfx/native_widget_types.h" #include "gfx/native_widget_types.h"
#include "skia/ext/platform_canvas.h" #include "skia/ext/platform_canvas.h"
#include "third_party/WebKit/WebKit/chromium/public/WebInputEvent.h" #include "third_party/WebKit/WebKit/chromium/public/WebInputEvent.h"
namespace gfx { namespace gfx {
class Size; class Size;
} }
namespace WebKit { namespace WebKit {
class WebWidget; class WebWidget;
class WebWidgetClient; class WebWidgetClient;
class WebKeyboardEvent; class WebKeyboardEvent;
struct WebScreenInfo; struct WebScreenInfo;
} }
// This class is a simple ViewHandle-based host for a WebWidget // This class is a simple ViewHandle-based host for a WebWidget
class WebWidgetHost { class WebWidgetHost {
public: public:
// The new instance is deleted once the associated ViewHandle is destroyed. // The new instance is deleted once the associated ViewHandle is destroyed.
// The newly created window should be resized after it is created, using the // The newly created window should be resized after it is created, using the
// MoveWindow (or equivalent) function. // MoveWindow (or equivalent) function.
static WebWidgetHost* Create(gfx::NativeView parent_view, static WebWidgetHost* Create(gfx::NativeView parent_view,
WebKit::WebWidgetClient* client); WebKit::WebWidgetClient* client);
#if defined(OS_MACOSX) #if defined(OS_MACOSX)
static void HandleEvent(gfx::NativeView view, NSEvent *event); static void HandleEvent(gfx::NativeView view, NSEvent *event);
#endif #endif
gfx::NativeView view_handle() const { return view_; } gfx::NativeView view_handle() const { return view_; }
WebKit::WebWidget* webwidget() const { return webwidget_; } WebKit::WebWidget* webwidget() const { return webwidget_; }
void DidInvalidateRect(const gfx::Rect& rect); void DidInvalidateRect(const gfx::Rect& rect);
void DidScrollRect(int dx, int dy, const gfx::Rect& clip_rect); void DidScrollRect(int dx, int dy, const gfx::Rect& clip_rect);
void ScheduleComposite(); void ScheduleComposite();
#if defined(OS_WIN) #if defined(OS_WIN)
void SetCursor(HCURSOR cursor); void SetCursor(HCURSOR cursor);
#endif #endif
void DiscardBackingStore(); void DiscardBackingStore();
// Allow clients to update the paint rect. For example, if we get a gdk // Allow clients to update the paint rect. For example, if we get a gdk
// expose or WM_PAINT event, we need to update the paint rect. // expose or WM_PAINT event, we need to update the paint rect.
void UpdatePaintRect(const gfx::Rect& rect); void UpdatePaintRect(const gfx::Rect& rect);
void Paint(); void Paint();
skia::PlatformCanvas* canvas() const { return canvas_.get(); } skia::PlatformCanvas* canvas() const { return canvas_.get(); }
WebKit::WebScreenInfo GetScreenInfo(); WebKit::WebScreenInfo GetScreenInfo();
WebKit::WebKeyboardEvent GetLastKeyEvent() const { return last_key_event_; } WebKit::WebKeyboardEvent GetLastKeyEvent() const { return last_key_event_; }
void PaintRect(const gfx::Rect& rect); void PaintRect(const gfx::Rect& rect);
void SetTooltipText(const std::wstring& tooltip_text); void SetTooltipText(const std::wstring& tooltip_text);
protected: protected:
WebWidgetHost(); WebWidgetHost();
~WebWidgetHost(); ~WebWidgetHost();
#if defined(OS_WIN) #if defined(OS_WIN)
// Per-class wndproc. Returns true if the event should be swallowed. // Per-class wndproc. Returns true if the event should be swallowed.
virtual bool WndProc(UINT message, WPARAM wparam, LPARAM lparam); virtual bool WndProc(UINT message, WPARAM wparam, LPARAM lparam);
void Resize(LPARAM lparam); void Resize(LPARAM lparam);
void MouseEvent(UINT message, WPARAM wparam, LPARAM lparam); void MouseEvent(UINT message, WPARAM wparam, LPARAM lparam);
void WheelEvent(WPARAM wparam, LPARAM lparam); void WheelEvent(WPARAM wparam, LPARAM lparam);
void KeyEvent(UINT message, WPARAM wparam, LPARAM lparam); void KeyEvent(UINT message, WPARAM wparam, LPARAM lparam);
void CaptureLostEvent(); void CaptureLostEvent();
void SetFocus(bool enable); void SetFocus(bool enable);
void OnNotify(WPARAM wparam, NMHDR* header); void OnNotify(WPARAM wparam, NMHDR* header);
static LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); static LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
#elif defined(OS_MACOSX) #elif defined(OS_MACOSX)
// These need to be called from a non-subclass, so they need to be public. // These need to be called from a non-subclass, so they need to be public.
public: public:
void Resize(const gfx::Rect& rect); void Resize(const gfx::Rect& rect);
void MouseEvent(NSEvent *); void MouseEvent(NSEvent *);
void WheelEvent(NSEvent *); void WheelEvent(NSEvent *);
void KeyEvent(NSEvent *); void KeyEvent(NSEvent *);
void SetFocus(bool enable); void SetFocus(bool enable);
protected: protected:
#elif defined(OS_LINUX) #elif defined(OS_LINUX)
public: public:
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
// This is needed on Linux because the GtkWidget creation is the same between // This is needed on Linux because the GtkWidget creation is the same between
// both web view hosts and web widget hosts. The Windows code manages this by // both web view hosts and web widget hosts. The Windows code manages this by
// reusing the WndProc function (static, above). However, GTK doesn't use a // reusing the WndProc function (static, above). However, GTK doesn't use a
// single big callback function like that so we have a static function that // single big callback function like that so we have a static function that
// sets up a GtkWidget correctly. // sets up a GtkWidget correctly.
// parent: a GtkBox to pack the new widget at the end of // parent: a GtkBox to pack the new widget at the end of
// host: a pointer to a WebWidgetHost (or subclass thereof) // host: a pointer to a WebWidgetHost (or subclass thereof)
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
static gfx::NativeView CreateWindow(gfx::NativeView parent_view, static gfx::NativeView CreateWindow(gfx::NativeView parent_view,
WebWidgetHost* host); WebWidgetHost* host);
void WindowDestroyed(); void WindowDestroyed();
void Resize(const gfx::Size& size); void Resize(const gfx::Size& size);
#endif #endif
void TrackMouseLeave(bool enable); void TrackMouseLeave(bool enable);
void ResetScrollRect(); void ResetScrollRect();
void set_painting(bool value) { void set_painting(bool value) {
#ifndef NDEBUG #ifndef NDEBUG
painting_ = value; painting_ = value;
#endif #endif
} }
void EnsureTooltip(); void EnsureTooltip();
void ResetTooltip(); void ResetTooltip();
gfx::NativeView view_; gfx::NativeView view_;
WebKit::WebWidget* webwidget_; WebKit::WebWidget* webwidget_;
scoped_ptr<skia::PlatformCanvas> canvas_; scoped_ptr<skia::PlatformCanvas> canvas_;
// specifies the portion of the webwidget that needs painting // specifies the portion of the webwidget that needs painting
gfx::Rect paint_rect_; gfx::Rect paint_rect_;
// specifies the portion of the webwidget that needs scrolling // specifies the portion of the webwidget that needs scrolling
gfx::Rect scroll_rect_; gfx::Rect scroll_rect_;
int scroll_dx_; int scroll_dx_;
int scroll_dy_; int scroll_dy_;
bool track_mouse_leave_; bool track_mouse_leave_;
WebKit::WebKeyboardEvent last_key_event_; WebKit::WebKeyboardEvent last_key_event_;
gfx::NativeView tooltip_view_; gfx::NativeView tooltip_view_;
std::wstring tooltip_text_; std::wstring tooltip_text_;
bool tooltip_showing_; bool tooltip_showing_;
#ifndef NDEBUG #ifndef NDEBUG
bool painting_; bool painting_;
#endif #endif
}; };
#endif // _WEBWIDGET_HOST_H #endif // _WEBWIDGET_HOST_H

View File

@ -1,10 +1,10 @@
// Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights // Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that // reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file. // can be found in the LICENSE file.
#ifdef BUILDING_CEF_SHARED #ifdef BUILDING_CEF_SHARED
#include "base/logging.h" #include "base/logging.h"
#else #else
#include <assert.h> #include <assert.h>
#define DCHECK(condition) assert(condition) #define DCHECK(condition) assert(condition)
#endif #endif

View File

@ -1,143 +1,143 @@
// Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights // Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that // reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file. // can be found in the LICENSE file.
#ifndef _BASE_CPPTOC_H #ifndef _BASE_CPPTOC_H
#define _BASE_CPPTOC_H #define _BASE_CPPTOC_H
#include "include/cef.h" #include "include/cef.h"
#include "include/cef_capi.h" #include "include/cef_capi.h"
#include "libcef_dll/cef_logging.h" #include "libcef_dll/cef_logging.h"
// CefCppToC implementation for CefBase. // CefCppToC implementation for CefBase.
class CefBaseCppToC : public CefThreadSafeBase<CefBase> class CefBaseCppToC : public CefThreadSafeBase<CefBase>
{ {
public: public:
// Use this method to retrieve the underlying class instance from our // Use this method to retrieve the underlying class instance from our
// own structure when the structure is passed as the required first // own structure when the structure is passed as the required first
// parameter of a C API function call. No explicit reference counting // parameter of a C API function call. No explicit reference counting
// is done in this case. // is done in this case.
static CefRefPtr<CefBase> Get(cef_base_t* s) static CefRefPtr<CefBase> Get(cef_base_t* s)
{ {
// Cast our structure to the wrapper structure type. // Cast our structure to the wrapper structure type.
CefBaseCppToC::Struct* wrapperStruct = CefBaseCppToC::Struct* wrapperStruct =
reinterpret_cast<CefBaseCppToC::Struct*>(s); reinterpret_cast<CefBaseCppToC::Struct*>(s);
// Return the underlying object instance. // Return the underlying object instance.
return wrapperStruct->class_->GetClass(); return wrapperStruct->class_->GetClass();
} }
// Use this method to create a wrapper structure for passing our class // Use this method to create a wrapper structure for passing our class
// instance to the other side. // instance to the other side.
static cef_base_t* Wrap(CefRefPtr<CefBase> c) static cef_base_t* Wrap(CefRefPtr<CefBase> c)
{ {
// Wrap our object with the CefCppToC class. // Wrap our object with the CefCppToC class.
CefBaseCppToC* wrapper = new CefBaseCppToC(c); CefBaseCppToC* wrapper = new CefBaseCppToC(c);
// Add a reference to our wrapper object that will be released once our // Add a reference to our wrapper object that will be released once our
// structure arrives on the other side. // structure arrives on the other side.
wrapper->AddRef(); wrapper->AddRef();
// Return the structure pointer that can now be passed to the other side. // Return the structure pointer that can now be passed to the other side.
return wrapper->GetStruct(); return wrapper->GetStruct();
} }
// Use this method to retrieve the underlying class instance when receiving // Use this method to retrieve the underlying class instance when receiving
// our wrapper structure back from the other side. // our wrapper structure back from the other side.
static CefRefPtr<CefBase> Unwrap(cef_base_t* s) static CefRefPtr<CefBase> Unwrap(cef_base_t* s)
{ {
// Cast our structure to the wrapper structure type. // Cast our structure to the wrapper structure type.
CefBaseCppToC::Struct* wrapperStruct = CefBaseCppToC::Struct* wrapperStruct =
reinterpret_cast<CefBaseCppToC::Struct*>(s); reinterpret_cast<CefBaseCppToC::Struct*>(s);
// Add the underlying object instance to a smart pointer. // Add the underlying object instance to a smart pointer.
CefRefPtr<CefBase> objectPtr(wrapperStruct->class_->GetClass()); CefRefPtr<CefBase> objectPtr(wrapperStruct->class_->GetClass());
// Release the reference to our wrapper object that was added before the // Release the reference to our wrapper object that was added before the
// structure was passed back to us. // structure was passed back to us.
wrapperStruct->class_->Release(); wrapperStruct->class_->Release();
// Return the underlying object instance. // Return the underlying object instance.
return objectPtr; return objectPtr;
} }
// Structure representation with pointer to the C++ class. // Structure representation with pointer to the C++ class.
struct Struct struct Struct
{ {
cef_base_t struct_; cef_base_t struct_;
CefBaseCppToC* class_; CefBaseCppToC* class_;
}; };
CefBaseCppToC(CefBase* cls) CefBaseCppToC(CefBase* cls)
: class_(cls) : class_(cls)
{ {
DCHECK(cls); DCHECK(cls);
struct_.class_ = this; struct_.class_ = this;
// zero the underlying structure and set base members // zero the underlying structure and set base members
memset(&struct_.struct_, 0, sizeof(cef_base_t)); memset(&struct_.struct_, 0, sizeof(cef_base_t));
struct_.struct_.size = sizeof(cef_base_t); struct_.struct_.size = sizeof(cef_base_t);
struct_.struct_.add_ref = struct_add_ref; struct_.struct_.add_ref = struct_add_ref;
struct_.struct_.release = struct_release; struct_.struct_.release = struct_release;
struct_.struct_.get_refct = struct_get_refct; struct_.struct_.get_refct = struct_get_refct;
} }
virtual ~CefBaseCppToC() {} virtual ~CefBaseCppToC() {}
CefBase* GetClass() { return class_; } CefBase* GetClass() { return class_; }
// If returning the structure across the DLL boundary you should call // If returning the structure across the DLL boundary you should call
// AddRef() on this CefCppToC object. On the other side of the DLL boundary, // AddRef() on this CefCppToC object. On the other side of the DLL boundary,
// call UnderlyingRelease() on the wrapping CefCToCpp object. // call UnderlyingRelease() on the wrapping CefCToCpp object.
cef_base_t* GetStruct() { return &struct_.struct_; } cef_base_t* GetStruct() { return &struct_.struct_; }
// CefBase methods increment/decrement reference counts on both this object // CefBase methods increment/decrement reference counts on both this object
// and the underlying wrapper class. // and the underlying wrapper class.
virtual int AddRef() virtual int AddRef()
{ {
UnderlyingAddRef(); UnderlyingAddRef();
return CefThreadSafeBase<CefBase>::AddRef(); return CefThreadSafeBase<CefBase>::AddRef();
} }
virtual int Release() virtual int Release()
{ {
UnderlyingRelease(); UnderlyingRelease();
return CefThreadSafeBase<CefBase>::Release(); return CefThreadSafeBase<CefBase>::Release();
} }
// Increment/decrement reference counts on only the underlying class. // Increment/decrement reference counts on only the underlying class.
int UnderlyingAddRef() { return class_->AddRef(); } int UnderlyingAddRef() { return class_->AddRef(); }
int UnderlyingRelease() { return class_->Release(); } int UnderlyingRelease() { return class_->Release(); }
int UnderlyingGetRefCt() { return class_->GetRefCt(); } int UnderlyingGetRefCt() { return class_->GetRefCt(); }
private: private:
static int CEF_CALLBACK struct_add_ref(struct _cef_base_t* base) static int CEF_CALLBACK struct_add_ref(struct _cef_base_t* base)
{ {
DCHECK(base); DCHECK(base);
if(!base) if(!base)
return 0; return 0;
Struct* impl = reinterpret_cast<Struct*>(base); Struct* impl = reinterpret_cast<Struct*>(base);
return impl->class_->AddRef(); return impl->class_->AddRef();
} }
static int CEF_CALLBACK struct_release(struct _cef_base_t* base) static int CEF_CALLBACK struct_release(struct _cef_base_t* base)
{ {
DCHECK(base); DCHECK(base);
if(!base) if(!base)
return 0; return 0;
Struct* impl = reinterpret_cast<Struct*>(base); Struct* impl = reinterpret_cast<Struct*>(base);
return impl->class_->Release(); return impl->class_->Release();
} }
static int CEF_CALLBACK struct_get_refct(struct _cef_base_t* base) static int CEF_CALLBACK struct_get_refct(struct _cef_base_t* base)
{ {
DCHECK(base); DCHECK(base);
if(!base) if(!base)
return 0; return 0;
Struct* impl = reinterpret_cast<Struct*>(base); Struct* impl = reinterpret_cast<Struct*>(base);
return impl->class_->GetRefCt(); return impl->class_->GetRefCt();
} }
protected: protected:
Struct struct_; Struct struct_;
CefBase* class_; CefBase* class_;
}; };
#endif // _BASE_CPPTOC_H #endif // _BASE_CPPTOC_H

View File

@ -1,284 +1,284 @@
// Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights // Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that // reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file. // can be found in the LICENSE file.
// //
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
// //
// A portion of this file was generated by the CEF translator tool. When // A portion of this file was generated by the CEF translator tool. When
// making changes by hand only do so within the body of existing function // making changes by hand only do so within the body of existing function
// implementations. See the translator.README.txt file in the tools directory // implementations. See the translator.README.txt file in the tools directory
// for more information. // for more information.
// //
#include "libcef_dll/cpptoc/browser_cpptoc.h" #include "libcef_dll/cpptoc/browser_cpptoc.h"
#include "libcef_dll/cpptoc/frame_cpptoc.h" #include "libcef_dll/cpptoc/frame_cpptoc.h"
#include "libcef_dll/ctocpp/handler_ctocpp.h" #include "libcef_dll/ctocpp/handler_ctocpp.h"
// GLOBAL FUNCTIONS - Body may be edited by hand. // GLOBAL FUNCTIONS - Body may be edited by hand.
CEF_EXPORT int cef_browser_create(cef_window_info_t* windowInfo, int popup, CEF_EXPORT int cef_browser_create(cef_window_info_t* windowInfo, int popup,
struct _cef_handler_t* handler, const wchar_t* url) struct _cef_handler_t* handler, const wchar_t* url)
{ {
DCHECK(windowInfo); DCHECK(windowInfo);
CefRefPtr<CefHandler> handlerPtr; CefRefPtr<CefHandler> handlerPtr;
std::wstring urlStr; std::wstring urlStr;
CefWindowInfo wi = *windowInfo; CefWindowInfo wi = *windowInfo;
if(handler) if(handler)
handlerPtr = CefHandlerCToCpp::Wrap(handler); handlerPtr = CefHandlerCToCpp::Wrap(handler);
if(url) if(url)
urlStr = url; urlStr = url;
return CefBrowser::CreateBrowser(wi, popup?true:false, handlerPtr, urlStr); return CefBrowser::CreateBrowser(wi, popup?true:false, handlerPtr, urlStr);
} }
CEF_EXPORT cef_browser_t* cef_browser_create_sync(cef_window_info_t* windowInfo, CEF_EXPORT cef_browser_t* cef_browser_create_sync(cef_window_info_t* windowInfo,
int popup, struct _cef_handler_t* handler, const wchar_t* url) int popup, struct _cef_handler_t* handler, const wchar_t* url)
{ {
DCHECK(windowInfo); DCHECK(windowInfo);
CefRefPtr<CefHandler> handlerPtr; CefRefPtr<CefHandler> handlerPtr;
std::wstring urlStr; std::wstring urlStr;
CefWindowInfo wi = *windowInfo; CefWindowInfo wi = *windowInfo;
if(handler) if(handler)
handlerPtr = CefHandlerCToCpp::Wrap(handler); handlerPtr = CefHandlerCToCpp::Wrap(handler);
if(url) if(url)
urlStr = url; urlStr = url;
CefRefPtr<CefBrowser> browserPtr( CefRefPtr<CefBrowser> browserPtr(
CefBrowser::CreateBrowserSync(wi, popup?true:false, handlerPtr, urlStr)); CefBrowser::CreateBrowserSync(wi, popup?true:false, handlerPtr, urlStr));
if(browserPtr.get()) if(browserPtr.get())
return CefBrowserCppToC::Wrap(browserPtr); return CefBrowserCppToC::Wrap(browserPtr);
return NULL; return NULL;
} }
// MEMBER FUNCTIONS - Body may be edited by hand. // MEMBER FUNCTIONS - Body may be edited by hand.
int CEF_CALLBACK browser_can_go_back(struct _cef_browser_t* self) int CEF_CALLBACK browser_can_go_back(struct _cef_browser_t* self)
{ {
DCHECK(self); DCHECK(self);
if(!self) if(!self)
return 0; return 0;
return CefBrowserCppToC::Get(self)->CanGoBack(); return CefBrowserCppToC::Get(self)->CanGoBack();
} }
void CEF_CALLBACK browser_go_back(struct _cef_browser_t* self) void CEF_CALLBACK browser_go_back(struct _cef_browser_t* self)
{ {
DCHECK(self); DCHECK(self);
if(!self) if(!self)
return; return;
CefBrowserCppToC::Get(self)->GoBack(); CefBrowserCppToC::Get(self)->GoBack();
} }
int CEF_CALLBACK browser_can_go_forward(struct _cef_browser_t* self) int CEF_CALLBACK browser_can_go_forward(struct _cef_browser_t* self)
{ {
DCHECK(self); DCHECK(self);
if(!self) if(!self)
return 0; return 0;
return CefBrowserCppToC::Get(self)->CanGoForward(); return CefBrowserCppToC::Get(self)->CanGoForward();
} }
void CEF_CALLBACK browser_go_forward(struct _cef_browser_t* self) void CEF_CALLBACK browser_go_forward(struct _cef_browser_t* self)
{ {
DCHECK(self); DCHECK(self);
if(!self) if(!self)
return; return;
CefBrowserCppToC::Get(self)->GoForward(); CefBrowserCppToC::Get(self)->GoForward();
} }
void CEF_CALLBACK browser_reload(struct _cef_browser_t* self) void CEF_CALLBACK browser_reload(struct _cef_browser_t* self)
{ {
DCHECK(self); DCHECK(self);
if(!self) if(!self)
return; return;
CefBrowserCppToC::Get(self)->Reload(); CefBrowserCppToC::Get(self)->Reload();
} }
void CEF_CALLBACK browser_reload_ignore_cache(struct _cef_browser_t* self) void CEF_CALLBACK browser_reload_ignore_cache(struct _cef_browser_t* self)
{ {
DCHECK(self); DCHECK(self);
if(!self) if(!self)
return; return;
CefBrowserCppToC::Get(self)->ReloadIgnoreCache(); CefBrowserCppToC::Get(self)->ReloadIgnoreCache();
} }
void CEF_CALLBACK browser_stop_load(struct _cef_browser_t* self) void CEF_CALLBACK browser_stop_load(struct _cef_browser_t* self)
{ {
DCHECK(self); DCHECK(self);
if(!self) if(!self)
return; return;
CefBrowserCppToC::Get(self)->StopLoad(); CefBrowserCppToC::Get(self)->StopLoad();
} }
void CEF_CALLBACK browser_set_focus(struct _cef_browser_t* self, int enable) void CEF_CALLBACK browser_set_focus(struct _cef_browser_t* self, int enable)
{ {
DCHECK(self); DCHECK(self);
if(!self) if(!self)
return; return;
CefBrowserCppToC::Get(self)->SetFocus(enable ? true : false); CefBrowserCppToC::Get(self)->SetFocus(enable ? true : false);
} }
cef_window_handle_t CEF_CALLBACK browser_get_window_handle( cef_window_handle_t CEF_CALLBACK browser_get_window_handle(
struct _cef_browser_t* self) struct _cef_browser_t* self)
{ {
DCHECK(self); DCHECK(self);
if(!self) if(!self)
return NULL; return NULL;
return CefBrowserCppToC::Get(self)->GetWindowHandle(); return CefBrowserCppToC::Get(self)->GetWindowHandle();
} }
int CEF_CALLBACK browser_is_popup(struct _cef_browser_t* self) int CEF_CALLBACK browser_is_popup(struct _cef_browser_t* self)
{ {
DCHECK(self); DCHECK(self);
if(!self) if(!self)
return 0; return 0;
return CefBrowserCppToC::Get(self)->IsPopup(); return CefBrowserCppToC::Get(self)->IsPopup();
} }
struct _cef_handler_t* CEF_CALLBACK browser_get_handler( struct _cef_handler_t* CEF_CALLBACK browser_get_handler(
struct _cef_browser_t* self) struct _cef_browser_t* self)
{ {
DCHECK(self); DCHECK(self);
if(!self) if(!self)
return NULL; return NULL;
CefRefPtr<CefBrowser> browserPtr = CefBrowserCppToC::Get(self); CefRefPtr<CefBrowser> browserPtr = CefBrowserCppToC::Get(self);
CefRefPtr<CefHandler> handlerPtr = browserPtr->GetHandler(); CefRefPtr<CefHandler> handlerPtr = browserPtr->GetHandler();
if(handlerPtr.get()) if(handlerPtr.get())
return CefHandlerCToCpp::Unwrap(handlerPtr); return CefHandlerCToCpp::Unwrap(handlerPtr);
return NULL; return NULL;
} }
struct _cef_frame_t* CEF_CALLBACK browser_get_main_frame( struct _cef_frame_t* CEF_CALLBACK browser_get_main_frame(
struct _cef_browser_t* self) struct _cef_browser_t* self)
{ {
DCHECK(self); DCHECK(self);
if(!self) if(!self)
return NULL; return NULL;
CefRefPtr<CefBrowser> browserPtr = CefBrowserCppToC::Get(self); CefRefPtr<CefBrowser> browserPtr = CefBrowserCppToC::Get(self);
CefRefPtr<CefFrame> framePtr = browserPtr->GetMainFrame(); CefRefPtr<CefFrame> framePtr = browserPtr->GetMainFrame();
if(framePtr.get()) if(framePtr.get())
return CefFrameCppToC::Wrap(framePtr); return CefFrameCppToC::Wrap(framePtr);
return NULL; return NULL;
} }
struct _cef_frame_t* CEF_CALLBACK browser_get_focused_frame( struct _cef_frame_t* CEF_CALLBACK browser_get_focused_frame(
struct _cef_browser_t* self) struct _cef_browser_t* self)
{ {
DCHECK(self); DCHECK(self);
if(!self) if(!self)
return NULL; return NULL;
CefRefPtr<CefBrowser> browserPtr = CefBrowserCppToC::Get(self); CefRefPtr<CefBrowser> browserPtr = CefBrowserCppToC::Get(self);
CefRefPtr<CefFrame> framePtr = browserPtr->GetFocusedFrame(); CefRefPtr<CefFrame> framePtr = browserPtr->GetFocusedFrame();
if(framePtr.get()) if(framePtr.get())
return CefFrameCppToC::Wrap(framePtr); return CefFrameCppToC::Wrap(framePtr);
return NULL; return NULL;
} }
struct _cef_frame_t* CEF_CALLBACK browser_get_frame(struct _cef_browser_t* self, struct _cef_frame_t* CEF_CALLBACK browser_get_frame(struct _cef_browser_t* self,
const wchar_t* name) const wchar_t* name)
{ {
DCHECK(self); DCHECK(self);
if(!self) if(!self)
return NULL; return NULL;
std::wstring nameStr; std::wstring nameStr;
if(name) if(name)
nameStr = name; nameStr = name;
if(nameStr.empty()) if(nameStr.empty())
return NULL; return NULL;
CefRefPtr<CefBrowser> browserPtr = CefBrowserCppToC::Get(self); CefRefPtr<CefBrowser> browserPtr = CefBrowserCppToC::Get(self);
CefRefPtr<CefFrame> framePtr = browserPtr->GetFrame(nameStr); CefRefPtr<CefFrame> framePtr = browserPtr->GetFrame(nameStr);
if(framePtr.get()) if(framePtr.get())
return CefFrameCppToC::Wrap(framePtr); return CefFrameCppToC::Wrap(framePtr);
return NULL; return NULL;
} }
void CEF_CALLBACK browser_get_frame_names(struct _cef_browser_t* self, void CEF_CALLBACK browser_get_frame_names(struct _cef_browser_t* self,
cef_string_list_t names) cef_string_list_t names)
{ {
DCHECK(self); DCHECK(self);
DCHECK(names); DCHECK(names);
if(!self || !names) if(!self || !names)
return; return;
CefRefPtr<CefBrowser> browserPtr = CefBrowserCppToC::Get(self); CefRefPtr<CefBrowser> browserPtr = CefBrowserCppToC::Get(self);
std::vector<std::wstring> stringList; std::vector<std::wstring> stringList;
browserPtr->GetFrameNames(stringList); browserPtr->GetFrameNames(stringList);
size_t size = stringList.size(); size_t size = stringList.size();
for(size_t i = 0; i < size; ++i) for(size_t i = 0; i < size; ++i)
cef_string_list_append(names, stringList[i].c_str()); cef_string_list_append(names, stringList[i].c_str());
} }
void CEF_CALLBACK browser_find(struct _cef_browser_t* self, int identifier, void CEF_CALLBACK browser_find(struct _cef_browser_t* self, int identifier,
const wchar_t* searchText, int forward, int matchCase, int findNext) const wchar_t* searchText, int forward, int matchCase, int findNext)
{ {
DCHECK(self); DCHECK(self);
if(!self) if(!self)
return; return;
std::wstring searchTextStr; std::wstring searchTextStr;
if(searchText) if(searchText)
searchTextStr = searchText; searchTextStr = searchText;
CefBrowserCppToC::Get(self)->Find(identifier, searchTextStr, CefBrowserCppToC::Get(self)->Find(identifier, searchTextStr,
forward?true:false, matchCase?true:false, findNext?true:false); forward?true:false, matchCase?true:false, findNext?true:false);
} }
void CEF_CALLBACK browser_stop_finding(struct _cef_browser_t* self, void CEF_CALLBACK browser_stop_finding(struct _cef_browser_t* self,
int clearSelection) int clearSelection)
{ {
DCHECK(self); DCHECK(self);
if(!self) if(!self)
return; return;
CefBrowserCppToC::Get(self)->StopFinding(clearSelection?true:false); CefBrowserCppToC::Get(self)->StopFinding(clearSelection?true:false);
} }
// CONSTRUCTOR - Do not edit by hand. // CONSTRUCTOR - Do not edit by hand.
CefBrowserCppToC::CefBrowserCppToC(CefBrowser* cls) CefBrowserCppToC::CefBrowserCppToC(CefBrowser* cls)
: CefCppToC<CefBrowserCppToC, CefBrowser, cef_browser_t>(cls) : CefCppToC<CefBrowserCppToC, CefBrowser, cef_browser_t>(cls)
{ {
struct_.struct_.can_go_back = browser_can_go_back; struct_.struct_.can_go_back = browser_can_go_back;
struct_.struct_.go_back = browser_go_back; struct_.struct_.go_back = browser_go_back;
struct_.struct_.can_go_forward = browser_can_go_forward; struct_.struct_.can_go_forward = browser_can_go_forward;
struct_.struct_.go_forward = browser_go_forward; struct_.struct_.go_forward = browser_go_forward;
struct_.struct_.reload = browser_reload; struct_.struct_.reload = browser_reload;
struct_.struct_.reload_ignore_cache = browser_reload_ignore_cache; struct_.struct_.reload_ignore_cache = browser_reload_ignore_cache;
struct_.struct_.stop_load = browser_stop_load; struct_.struct_.stop_load = browser_stop_load;
struct_.struct_.set_focus = browser_set_focus; struct_.struct_.set_focus = browser_set_focus;
struct_.struct_.get_window_handle = browser_get_window_handle; struct_.struct_.get_window_handle = browser_get_window_handle;
struct_.struct_.is_popup = browser_is_popup; struct_.struct_.is_popup = browser_is_popup;
struct_.struct_.get_handler = browser_get_handler; struct_.struct_.get_handler = browser_get_handler;
struct_.struct_.get_main_frame = browser_get_main_frame; struct_.struct_.get_main_frame = browser_get_main_frame;
struct_.struct_.get_focused_frame = browser_get_focused_frame; struct_.struct_.get_focused_frame = browser_get_focused_frame;
struct_.struct_.get_frame = browser_get_frame; struct_.struct_.get_frame = browser_get_frame;
struct_.struct_.get_frame_names = browser_get_frame_names; struct_.struct_.get_frame_names = browser_get_frame_names;
struct_.struct_.find = browser_find; struct_.struct_.find = browser_find;
struct_.struct_.stop_finding = browser_stop_finding; struct_.struct_.stop_finding = browser_stop_finding;
} }
#ifdef _DEBUG #ifdef _DEBUG
long CefCppToC<CefBrowserCppToC, CefBrowser, cef_browser_t>::DebugObjCt = 0; long CefCppToC<CefBrowserCppToC, CefBrowser, cef_browser_t>::DebugObjCt = 0;
#endif #endif

View File

@ -1,34 +1,34 @@
// Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights // Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that // reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file. // can be found in the LICENSE file.
// //
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
// //
// This file was generated by the CEF translator tool and should not edited // 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 // by hand. See the translator.README.txt file in the tools directory for
// more information. // more information.
// //
#ifndef _BROWSER_CPPTOC_H #ifndef _BROWSER_CPPTOC_H
#define _BROWSER_CPPTOC_H #define _BROWSER_CPPTOC_H
#ifndef BUILDING_CEF_SHARED #ifndef BUILDING_CEF_SHARED
#pragma message("Warning: "__FILE__" may be accessed DLL-side only") #pragma message("Warning: "__FILE__" may be accessed DLL-side only")
#else // BUILDING_CEF_SHARED #else // BUILDING_CEF_SHARED
#include "include/cef.h" #include "include/cef.h"
#include "include/cef_capi.h" #include "include/cef_capi.h"
#include "libcef_dll/cpptoc/cpptoc.h" #include "libcef_dll/cpptoc/cpptoc.h"
// Wrap a C++ class with a C structure. // Wrap a C++ class with a C structure.
// This class may be instantiated and accessed DLL-side only. // This class may be instantiated and accessed DLL-side only.
class CefBrowserCppToC class CefBrowserCppToC
: public CefCppToC<CefBrowserCppToC, CefBrowser, cef_browser_t> : public CefCppToC<CefBrowserCppToC, CefBrowser, cef_browser_t>
{ {
public: public:
CefBrowserCppToC(CefBrowser* cls); CefBrowserCppToC(CefBrowser* cls);
virtual ~CefBrowserCppToC() {} virtual ~CefBrowserCppToC() {}
}; };
#endif // BUILDING_CEF_SHARED #endif // BUILDING_CEF_SHARED
#endif // _BROWSER_CPPTOC_H #endif // _BROWSER_CPPTOC_H

View File

@ -1,160 +1,160 @@
// Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights // Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that // reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file. // can be found in the LICENSE file.
#ifndef _CPPTOC_H #ifndef _CPPTOC_H
#define _CPPTOC_H #define _CPPTOC_H
#include "include/cef.h" #include "include/cef.h"
#include "include/cef_capi.h" #include "include/cef_capi.h"
#include "libcef_dll/cef_logging.h" #include "libcef_dll/cef_logging.h"
// Wrap a C++ class with a C structure. This is used when the class // Wrap a C++ class with a C structure. This is used when the class
// implementation exists on this side of the DLL boundary but will have methods // implementation exists on this side of the DLL boundary but will have methods
// called from the other side of the DLL boundary. // called from the other side of the DLL boundary.
template <class ClassName, class BaseName, class StructName> template <class ClassName, class BaseName, class StructName>
class CefCppToC : public CefThreadSafeBase<CefBase> class CefCppToC : public CefThreadSafeBase<CefBase>
{ {
public: public:
// Use this method to retrieve the underlying class instance from our // Use this method to retrieve the underlying class instance from our
// own structure when the structure is passed as the required first // own structure when the structure is passed as the required first
// parameter of a C API function call. No explicit reference counting // parameter of a C API function call. No explicit reference counting
// is done in this case. // is done in this case.
static CefRefPtr<BaseName> Get(StructName* s) static CefRefPtr<BaseName> Get(StructName* s)
{ {
// Cast our structure to the wrapper structure type. // Cast our structure to the wrapper structure type.
ClassName::Struct* wrapperStruct = ClassName::Struct* wrapperStruct =
reinterpret_cast<ClassName::Struct*>(s); reinterpret_cast<ClassName::Struct*>(s);
// Return the underlying object instance. // Return the underlying object instance.
return wrapperStruct->class_->GetClass(); return wrapperStruct->class_->GetClass();
} }
// Use this method to create a wrapper structure for passing our class // Use this method to create a wrapper structure for passing our class
// instance to the other side. // instance to the other side.
static StructName* Wrap(CefRefPtr<BaseName> c) static StructName* Wrap(CefRefPtr<BaseName> c)
{ {
// Wrap our object with the CefCppToC class. // Wrap our object with the CefCppToC class.
ClassName* wrapper = new ClassName(c); ClassName* wrapper = new ClassName(c);
// Add a reference to our wrapper object that will be released once our // Add a reference to our wrapper object that will be released once our
// structure arrives on the other side. // structure arrives on the other side.
wrapper->AddRef(); wrapper->AddRef();
// Return the structure pointer that can now be passed to the other side. // Return the structure pointer that can now be passed to the other side.
return wrapper->GetStruct(); return wrapper->GetStruct();
} }
// Use this method to retrieve the underlying class instance when receiving // Use this method to retrieve the underlying class instance when receiving
// our wrapper structure back from the other side. // our wrapper structure back from the other side.
static CefRefPtr<BaseName> Unwrap(StructName* s) static CefRefPtr<BaseName> Unwrap(StructName* s)
{ {
// Cast our structure to the wrapper structure type. // Cast our structure to the wrapper structure type.
ClassName::Struct* wrapperStruct = ClassName::Struct* wrapperStruct =
reinterpret_cast<ClassName::Struct*>(s); reinterpret_cast<ClassName::Struct*>(s);
// Add the underlying object instance to a smart pointer. // Add the underlying object instance to a smart pointer.
CefRefPtr<BaseName> objectPtr(wrapperStruct->class_->GetClass()); CefRefPtr<BaseName> objectPtr(wrapperStruct->class_->GetClass());
// Release the reference to our wrapper object that was added before the // Release the reference to our wrapper object that was added before the
// structure was passed back to us. // structure was passed back to us.
wrapperStruct->class_->Release(); wrapperStruct->class_->Release();
// Return the underlying object instance. // Return the underlying object instance.
return objectPtr; return objectPtr;
} }
// Structure representation with pointer to the C++ class. // Structure representation with pointer to the C++ class.
struct Struct struct Struct
{ {
StructName struct_; StructName struct_;
CefCppToC<ClassName,BaseName,StructName>* class_; CefCppToC<ClassName,BaseName,StructName>* class_;
}; };
CefCppToC(BaseName* cls) CefCppToC(BaseName* cls)
: class_(cls) : class_(cls)
{ {
DCHECK(cls); DCHECK(cls);
struct_.class_ = this; struct_.class_ = this;
// zero the underlying structure and set base members // zero the underlying structure and set base members
memset(&struct_.struct_, 0, sizeof(StructName)); memset(&struct_.struct_, 0, sizeof(StructName));
struct_.struct_.base.size = sizeof(StructName); struct_.struct_.base.size = sizeof(StructName);
struct_.struct_.base.add_ref = struct_add_ref; struct_.struct_.base.add_ref = struct_add_ref;
struct_.struct_.base.release = struct_release; struct_.struct_.base.release = struct_release;
struct_.struct_.base.get_refct = struct_get_refct; struct_.struct_.base.get_refct = struct_get_refct;
#ifdef _DEBUG #ifdef _DEBUG
CefAtomicIncrement(&DebugObjCt); CefAtomicIncrement(&DebugObjCt);
#endif #endif
} }
virtual ~CefCppToC() virtual ~CefCppToC()
{ {
#ifdef _DEBUG #ifdef _DEBUG
CefAtomicDecrement(&DebugObjCt); CefAtomicDecrement(&DebugObjCt);
#endif #endif
} }
BaseName* GetClass() { return class_; } BaseName* GetClass() { return class_; }
// If returning the structure across the DLL boundary you should call // If returning the structure across the DLL boundary you should call
// AddRef() on this CefCppToC object. On the other side of the DLL boundary, // AddRef() on this CefCppToC object. On the other side of the DLL boundary,
// call UnderlyingRelease() on the wrapping CefCToCpp object. // call UnderlyingRelease() on the wrapping CefCToCpp object.
StructName* GetStruct() { return &struct_.struct_; } StructName* GetStruct() { return &struct_.struct_; }
// CefBase methods increment/decrement reference counts on both this object // CefBase methods increment/decrement reference counts on both this object
// and the underlying wrapper class. // and the underlying wrapper class.
virtual int AddRef() virtual int AddRef()
{ {
UnderlyingAddRef(); UnderlyingAddRef();
return CefThreadSafeBase<CefBase>::AddRef(); return CefThreadSafeBase<CefBase>::AddRef();
} }
virtual int Release() virtual int Release()
{ {
UnderlyingRelease(); UnderlyingRelease();
return CefThreadSafeBase<CefBase>::Release(); return CefThreadSafeBase<CefBase>::Release();
} }
// Increment/decrement reference counts on only the underlying class. // Increment/decrement reference counts on only the underlying class.
int UnderlyingAddRef() { return class_->AddRef(); } int UnderlyingAddRef() { return class_->AddRef(); }
int UnderlyingRelease() { return class_->Release(); } int UnderlyingRelease() { return class_->Release(); }
int UnderlyingGetRefCt() { return class_->GetRefCt(); } int UnderlyingGetRefCt() { return class_->GetRefCt(); }
#ifdef _DEBUG #ifdef _DEBUG
// Simple tracking of allocated objects. // Simple tracking of allocated objects.
static long DebugObjCt; static long DebugObjCt;
#endif #endif
private: private:
static int CEF_CALLBACK struct_add_ref(struct _cef_base_t* base) static int CEF_CALLBACK struct_add_ref(struct _cef_base_t* base)
{ {
DCHECK(base); DCHECK(base);
if(!base) if(!base)
return 0; return 0;
Struct* impl = reinterpret_cast<Struct*>(base); Struct* impl = reinterpret_cast<Struct*>(base);
return impl->class_->AddRef(); return impl->class_->AddRef();
} }
static int CEF_CALLBACK struct_release(struct _cef_base_t* base) static int CEF_CALLBACK struct_release(struct _cef_base_t* base)
{ {
DCHECK(base); DCHECK(base);
if(!base) if(!base)
return 0; return 0;
Struct* impl = reinterpret_cast<Struct*>(base); Struct* impl = reinterpret_cast<Struct*>(base);
return impl->class_->Release(); return impl->class_->Release();
} }
static int CEF_CALLBACK struct_get_refct(struct _cef_base_t* base) static int CEF_CALLBACK struct_get_refct(struct _cef_base_t* base)
{ {
DCHECK(base); DCHECK(base);
if(!base) if(!base)
return 0; return 0;
Struct* impl = reinterpret_cast<Struct*>(base); Struct* impl = reinterpret_cast<Struct*>(base);
return impl->class_->GetRefCt(); return impl->class_->GetRefCt();
} }
protected: protected:
Struct struct_; Struct struct_;
BaseName* class_; BaseName* class_;
}; };
#endif // _CPPTOC_H #endif // _CPPTOC_H

View File

@ -1,270 +1,270 @@
// Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights // Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that // reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file. // can be found in the LICENSE file.
// //
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
// //
// A portion of this file was generated by the CEF translator tool. When // A portion of this file was generated by the CEF translator tool. When
// making changes by hand only do so within the body of existing function // making changes by hand only do so within the body of existing function
// implementations. See the translator.README.txt file in the tools directory // implementations. See the translator.README.txt file in the tools directory
// for more information. // for more information.
// //
#include "libcef_dll/cpptoc/frame_cpptoc.h" #include "libcef_dll/cpptoc/frame_cpptoc.h"
#include "libcef_dll/cpptoc/request_cpptoc.h" #include "libcef_dll/cpptoc/request_cpptoc.h"
#include "libcef_dll/cpptoc/stream_reader_cpptoc.h" #include "libcef_dll/cpptoc/stream_reader_cpptoc.h"
// MEMBER FUNCTIONS - Body may be edited by hand. // MEMBER FUNCTIONS - Body may be edited by hand.
void CEF_CALLBACK frame_undo(struct _cef_frame_t* self) void CEF_CALLBACK frame_undo(struct _cef_frame_t* self)
{ {
DCHECK(self); DCHECK(self);
if(!self) if(!self)
return; return;
CefFrameCppToC::Get(self)->Undo(); CefFrameCppToC::Get(self)->Undo();
} }
void CEF_CALLBACK frame_redo(struct _cef_frame_t* self) void CEF_CALLBACK frame_redo(struct _cef_frame_t* self)
{ {
DCHECK(self); DCHECK(self);
if(!self) if(!self)
return; return;
CefFrameCppToC::Get(self)->Redo(); CefFrameCppToC::Get(self)->Redo();
} }
void CEF_CALLBACK frame_cut(struct _cef_frame_t* self) void CEF_CALLBACK frame_cut(struct _cef_frame_t* self)
{ {
DCHECK(self); DCHECK(self);
if(!self) if(!self)
return; return;
CefFrameCppToC::Get(self)->Cut(); CefFrameCppToC::Get(self)->Cut();
} }
void CEF_CALLBACK frame_copy(struct _cef_frame_t* self) void CEF_CALLBACK frame_copy(struct _cef_frame_t* self)
{ {
DCHECK(self); DCHECK(self);
if(!self) if(!self)
return; return;
CefFrameCppToC::Get(self)->Copy(); CefFrameCppToC::Get(self)->Copy();
} }
void CEF_CALLBACK frame_paste(struct _cef_frame_t* self) void CEF_CALLBACK frame_paste(struct _cef_frame_t* self)
{ {
DCHECK(self); DCHECK(self);
if(!self) if(!self)
return; return;
CefFrameCppToC::Get(self)->Paste(); CefFrameCppToC::Get(self)->Paste();
} }
void CEF_CALLBACK frame_del(struct _cef_frame_t* self) void CEF_CALLBACK frame_del(struct _cef_frame_t* self)
{ {
DCHECK(self); DCHECK(self);
if(!self) if(!self)
return; return;
CefFrameCppToC::Get(self)->Delete(); CefFrameCppToC::Get(self)->Delete();
} }
void CEF_CALLBACK frame_select_all(struct _cef_frame_t* self) void CEF_CALLBACK frame_select_all(struct _cef_frame_t* self)
{ {
DCHECK(self); DCHECK(self);
if(!self) if(!self)
return; return;
CefFrameCppToC::Get(self)->SelectAll(); CefFrameCppToC::Get(self)->SelectAll();
} }
void CEF_CALLBACK frame_print(struct _cef_frame_t* self) void CEF_CALLBACK frame_print(struct _cef_frame_t* self)
{ {
DCHECK(self); DCHECK(self);
if(!self) if(!self)
return; return;
CefFrameCppToC::Get(self)->Print(); CefFrameCppToC::Get(self)->Print();
} }
void CEF_CALLBACK frame_view_source(struct _cef_frame_t* self) void CEF_CALLBACK frame_view_source(struct _cef_frame_t* self)
{ {
DCHECK(self); DCHECK(self);
if(!self) if(!self)
return; return;
CefFrameCppToC::Get(self)->ViewSource(); CefFrameCppToC::Get(self)->ViewSource();
} }
cef_string_t CEF_CALLBACK frame_get_source(struct _cef_frame_t* self) cef_string_t CEF_CALLBACK frame_get_source(struct _cef_frame_t* self)
{ {
DCHECK(self); DCHECK(self);
if(!self) if(!self)
return NULL; return NULL;
std::wstring sourceStr = CefFrameCppToC::Get(self)->GetSource(); std::wstring sourceStr = CefFrameCppToC::Get(self)->GetSource();
if(!sourceStr.empty()) if(!sourceStr.empty())
return cef_string_alloc(sourceStr.c_str()); return cef_string_alloc(sourceStr.c_str());
return NULL; return NULL;
} }
cef_string_t CEF_CALLBACK frame_get_text(struct _cef_frame_t* self) cef_string_t CEF_CALLBACK frame_get_text(struct _cef_frame_t* self)
{ {
DCHECK(self); DCHECK(self);
if(!self) if(!self)
return NULL; return NULL;
std::wstring textStr = CefFrameCppToC::Get(self)->GetText(); std::wstring textStr = CefFrameCppToC::Get(self)->GetText();
if(!textStr.empty()) if(!textStr.empty())
return cef_string_alloc(textStr.c_str()); return cef_string_alloc(textStr.c_str());
return NULL; return NULL;
} }
void CEF_CALLBACK frame_load_request(struct _cef_frame_t* self, void CEF_CALLBACK frame_load_request(struct _cef_frame_t* self,
struct _cef_request_t* request) struct _cef_request_t* request)
{ {
DCHECK(self); DCHECK(self);
DCHECK(request); DCHECK(request);
if(!self || !request) if(!self || !request)
return; return;
CefRefPtr<CefRequest> requestPtr = CefRequestCppToC::Unwrap(request); CefRefPtr<CefRequest> requestPtr = CefRequestCppToC::Unwrap(request);
CefFrameCppToC::Get(self)->LoadRequest(requestPtr); CefFrameCppToC::Get(self)->LoadRequest(requestPtr);
} }
void CEF_CALLBACK frame_load_url(struct _cef_frame_t* self, const wchar_t* url) void CEF_CALLBACK frame_load_url(struct _cef_frame_t* self, const wchar_t* url)
{ {
DCHECK(self); DCHECK(self);
if(!self) if(!self)
return; return;
std::wstring urlStr; std::wstring urlStr;
if(url) if(url)
urlStr = url; urlStr = url;
CefFrameCppToC::Get(self)->LoadURL(urlStr); CefFrameCppToC::Get(self)->LoadURL(urlStr);
} }
void CEF_CALLBACK frame_load_string(struct _cef_frame_t* self, void CEF_CALLBACK frame_load_string(struct _cef_frame_t* self,
const wchar_t* string, const wchar_t* url) const wchar_t* string, const wchar_t* url)
{ {
DCHECK(self); DCHECK(self);
if(!self) if(!self)
return; return;
std::wstring stringStr, urlStr; std::wstring stringStr, urlStr;
if(string) if(string)
stringStr = string; stringStr = string;
if(url) if(url)
urlStr = url; urlStr = url;
CefFrameCppToC::Get(self)->LoadString(stringStr, urlStr); CefFrameCppToC::Get(self)->LoadString(stringStr, urlStr);
} }
void CEF_CALLBACK frame_load_stream(struct _cef_frame_t* self, void CEF_CALLBACK frame_load_stream(struct _cef_frame_t* self,
struct _cef_stream_reader_t* stream, const wchar_t* url) struct _cef_stream_reader_t* stream, const wchar_t* url)
{ {
DCHECK(self); DCHECK(self);
DCHECK(stream); DCHECK(stream);
if(!self || !stream) if(!self || !stream)
return; return;
CefRefPtr<CefStreamReader> streamPtr = CefStreamReaderCppToC::Unwrap(stream); CefRefPtr<CefStreamReader> streamPtr = CefStreamReaderCppToC::Unwrap(stream);
std::wstring urlStr; std::wstring urlStr;
if(url) if(url)
urlStr = url; urlStr = url;
CefFrameCppToC::Get(self)->LoadStream(streamPtr, urlStr); CefFrameCppToC::Get(self)->LoadStream(streamPtr, urlStr);
} }
void CEF_CALLBACK frame_execute_java_script(struct _cef_frame_t* self, void CEF_CALLBACK frame_execute_java_script(struct _cef_frame_t* self,
const wchar_t* jsCode, const wchar_t* scriptUrl, int startLine) const wchar_t* jsCode, const wchar_t* scriptUrl, int startLine)
{ {
DCHECK(self); DCHECK(self);
if(!self) if(!self)
return; return;
std::wstring jsCodeStr, scriptUrlStr; std::wstring jsCodeStr, scriptUrlStr;
if(jsCode) if(jsCode)
jsCodeStr = jsCode; jsCodeStr = jsCode;
if(scriptUrl) if(scriptUrl)
scriptUrlStr = scriptUrl; scriptUrlStr = scriptUrl;
CefFrameCppToC::Get(self)->ExecuteJavaScript(jsCodeStr, scriptUrlStr, CefFrameCppToC::Get(self)->ExecuteJavaScript(jsCodeStr, scriptUrlStr,
startLine); startLine);
} }
int CEF_CALLBACK frame_is_main(struct _cef_frame_t* self) int CEF_CALLBACK frame_is_main(struct _cef_frame_t* self)
{ {
DCHECK(self); DCHECK(self);
if(!self) if(!self)
return 0; return 0;
return CefFrameCppToC::Get(self)->IsMain(); return CefFrameCppToC::Get(self)->IsMain();
} }
int CEF_CALLBACK frame_is_focused(struct _cef_frame_t* self) int CEF_CALLBACK frame_is_focused(struct _cef_frame_t* self)
{ {
DCHECK(self); DCHECK(self);
if(!self) if(!self)
return 0; return 0;
return CefFrameCppToC::Get(self)->IsFocused(); return CefFrameCppToC::Get(self)->IsFocused();
} }
cef_string_t CEF_CALLBACK frame_get_name(struct _cef_frame_t* self) cef_string_t CEF_CALLBACK frame_get_name(struct _cef_frame_t* self)
{ {
DCHECK(self); DCHECK(self);
if(!self) if(!self)
return 0; return 0;
std::wstring nameStr = CefFrameCppToC::Get(self)->GetName(); std::wstring nameStr = CefFrameCppToC::Get(self)->GetName();
if(!nameStr.empty()) if(!nameStr.empty())
return cef_string_alloc(nameStr.c_str()); return cef_string_alloc(nameStr.c_str());
return NULL; return NULL;
} }
cef_string_t CEF_CALLBACK frame_get_url(struct _cef_frame_t* self) cef_string_t CEF_CALLBACK frame_get_url(struct _cef_frame_t* self)
{ {
DCHECK(self); DCHECK(self);
if(!self) if(!self)
return NULL; return NULL;
std::wstring urlStr = CefFrameCppToC::Get(self)->GetURL(); std::wstring urlStr = CefFrameCppToC::Get(self)->GetURL();
if(!urlStr.empty()) if(!urlStr.empty())
return cef_string_alloc(urlStr.c_str()); return cef_string_alloc(urlStr.c_str());
return NULL; return NULL;
} }
// CONSTRUCTOR - Do not edit by hand. // CONSTRUCTOR - Do not edit by hand.
CefFrameCppToC::CefFrameCppToC(CefFrame* cls) CefFrameCppToC::CefFrameCppToC(CefFrame* cls)
: CefCppToC<CefFrameCppToC, CefFrame, cef_frame_t>(cls) : CefCppToC<CefFrameCppToC, CefFrame, cef_frame_t>(cls)
{ {
struct_.struct_.undo = frame_undo; struct_.struct_.undo = frame_undo;
struct_.struct_.redo = frame_redo; struct_.struct_.redo = frame_redo;
struct_.struct_.cut = frame_cut; struct_.struct_.cut = frame_cut;
struct_.struct_.copy = frame_copy; struct_.struct_.copy = frame_copy;
struct_.struct_.paste = frame_paste; struct_.struct_.paste = frame_paste;
struct_.struct_.del = frame_del; struct_.struct_.del = frame_del;
struct_.struct_.select_all = frame_select_all; struct_.struct_.select_all = frame_select_all;
struct_.struct_.print = frame_print; struct_.struct_.print = frame_print;
struct_.struct_.view_source = frame_view_source; struct_.struct_.view_source = frame_view_source;
struct_.struct_.get_source = frame_get_source; struct_.struct_.get_source = frame_get_source;
struct_.struct_.get_text = frame_get_text; struct_.struct_.get_text = frame_get_text;
struct_.struct_.load_request = frame_load_request; struct_.struct_.load_request = frame_load_request;
struct_.struct_.load_url = frame_load_url; struct_.struct_.load_url = frame_load_url;
struct_.struct_.load_string = frame_load_string; struct_.struct_.load_string = frame_load_string;
struct_.struct_.load_stream = frame_load_stream; struct_.struct_.load_stream = frame_load_stream;
struct_.struct_.execute_java_script = frame_execute_java_script; struct_.struct_.execute_java_script = frame_execute_java_script;
struct_.struct_.is_main = frame_is_main; struct_.struct_.is_main = frame_is_main;
struct_.struct_.is_focused = frame_is_focused; struct_.struct_.is_focused = frame_is_focused;
struct_.struct_.get_name = frame_get_name; struct_.struct_.get_name = frame_get_name;
struct_.struct_.get_url = frame_get_url; struct_.struct_.get_url = frame_get_url;
} }
#ifdef _DEBUG #ifdef _DEBUG
long CefCppToC<CefFrameCppToC, CefFrame, cef_frame_t>::DebugObjCt = 0; long CefCppToC<CefFrameCppToC, CefFrame, cef_frame_t>::DebugObjCt = 0;
#endif #endif

View File

@ -1,34 +1,34 @@
// Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights // Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that // reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file. // can be found in the LICENSE file.
// //
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
// //
// This file was generated by the CEF translator tool and should not edited // 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 // by hand. See the translator.README.txt file in the tools directory for
// more information. // more information.
// //
#ifndef _FRAME_CPPTOC_H #ifndef _FRAME_CPPTOC_H
#define _FRAME_CPPTOC_H #define _FRAME_CPPTOC_H
#ifndef BUILDING_CEF_SHARED #ifndef BUILDING_CEF_SHARED
#pragma message("Warning: "__FILE__" may be accessed DLL-side only") #pragma message("Warning: "__FILE__" may be accessed DLL-side only")
#else // BUILDING_CEF_SHARED #else // BUILDING_CEF_SHARED
#include "include/cef.h" #include "include/cef.h"
#include "include/cef_capi.h" #include "include/cef_capi.h"
#include "libcef_dll/cpptoc/cpptoc.h" #include "libcef_dll/cpptoc/cpptoc.h"
// Wrap a C++ class with a C structure. // Wrap a C++ class with a C structure.
// This class may be instantiated and accessed DLL-side only. // This class may be instantiated and accessed DLL-side only.
class CefFrameCppToC class CefFrameCppToC
: public CefCppToC<CefFrameCppToC, CefFrame, cef_frame_t> : public CefCppToC<CefFrameCppToC, CefFrame, cef_frame_t>
{ {
public: public:
CefFrameCppToC(CefFrame* cls); CefFrameCppToC(CefFrame* cls);
virtual ~CefFrameCppToC() {} virtual ~CefFrameCppToC() {}
}; };
#endif // BUILDING_CEF_SHARED #endif // BUILDING_CEF_SHARED
#endif // _FRAME_CPPTOC_H #endif // _FRAME_CPPTOC_H

File diff suppressed because it is too large Load Diff

View File

@ -1,34 +1,34 @@
// Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights // Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that // reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file. // can be found in the LICENSE file.
// //
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
// //
// This file was generated by the CEF translator tool and should not edited // 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 // by hand. See the translator.README.txt file in the tools directory for
// more information. // more information.
// //
#ifndef _HANDLER_CPPTOC_H #ifndef _HANDLER_CPPTOC_H
#define _HANDLER_CPPTOC_H #define _HANDLER_CPPTOC_H
#ifndef USING_CEF_SHARED #ifndef USING_CEF_SHARED
#pragma message("Warning: "__FILE__" may be accessed wrapper-side only") #pragma message("Warning: "__FILE__" may be accessed wrapper-side only")
#else // USING_CEF_SHARED #else // USING_CEF_SHARED
#include "include/cef.h" #include "include/cef.h"
#include "include/cef_capi.h" #include "include/cef_capi.h"
#include "libcef_dll/cpptoc/cpptoc.h" #include "libcef_dll/cpptoc/cpptoc.h"
// Wrap a C++ class with a C structure. // Wrap a C++ class with a C structure.
// This class may be instantiated and accessed wrapper-side only. // This class may be instantiated and accessed wrapper-side only.
class CefHandlerCppToC class CefHandlerCppToC
: public CefCppToC<CefHandlerCppToC, CefHandler, cef_handler_t> : public CefCppToC<CefHandlerCppToC, CefHandler, cef_handler_t>
{ {
public: public:
CefHandlerCppToC(CefHandler* cls); CefHandlerCppToC(CefHandler* cls);
virtual ~CefHandlerCppToC() {} virtual ~CefHandlerCppToC() {}
}; };
#endif // USING_CEF_SHARED #endif // USING_CEF_SHARED
#endif // _HANDLER_CPPTOC_H #endif // _HANDLER_CPPTOC_H

View File

@ -1,106 +1,106 @@
// Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights // Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that // reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file. // can be found in the LICENSE file.
// //
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
// //
// A portion of this file was generated by the CEF translator tool. When // A portion of this file was generated by the CEF translator tool. When
// making changes by hand only do so within the body of existing function // making changes by hand only do so within the body of existing function
// implementations. See the translator.README.txt file in the tools directory // implementations. See the translator.README.txt file in the tools directory
// for more information. // for more information.
// //
#include "libcef_dll/cpptoc/post_data_cpptoc.h" #include "libcef_dll/cpptoc/post_data_cpptoc.h"
#include "libcef_dll/cpptoc/post_data_element_cpptoc.h" #include "libcef_dll/cpptoc/post_data_element_cpptoc.h"
// GLOBAL FUNCTIONS - Body may be edited by hand. // GLOBAL FUNCTIONS - Body may be edited by hand.
CEF_EXPORT cef_post_data_t* cef_post_data_create() CEF_EXPORT cef_post_data_t* cef_post_data_create()
{ {
CefRefPtr<CefPostData> impl = CefPostData::CreatePostData(); CefRefPtr<CefPostData> impl = CefPostData::CreatePostData();
if(impl.get()) if(impl.get())
return CefPostDataCppToC::Wrap(impl); return CefPostDataCppToC::Wrap(impl);
return NULL; return NULL;
} }
// MEMBER FUNCTIONS - Body may be edited by hand. // MEMBER FUNCTIONS - Body may be edited by hand.
size_t CEF_CALLBACK post_data_get_element_count(struct _cef_post_data_t* self) size_t CEF_CALLBACK post_data_get_element_count(struct _cef_post_data_t* self)
{ {
DCHECK(self); DCHECK(self);
if(!self) if(!self)
return 0; return 0;
return CefPostDataCppToC::Get(self)->GetElementCount(); return CefPostDataCppToC::Get(self)->GetElementCount();
} }
struct _cef_post_data_element_t* CEF_CALLBACK post_data_get_elements( struct _cef_post_data_element_t* CEF_CALLBACK post_data_get_elements(
struct _cef_post_data_t* self, int elementIndex) struct _cef_post_data_t* self, int elementIndex)
{ {
DCHECK(self); DCHECK(self);
if(!self) if(!self)
return NULL; return NULL;
CefPostData::ElementVector elements; CefPostData::ElementVector elements;
CefPostDataCppToC::Get(self)->GetElements(elements); CefPostDataCppToC::Get(self)->GetElements(elements);
if(elementIndex < 0 || elementIndex >= (int)elements.size()) if(elementIndex < 0 || elementIndex >= (int)elements.size())
return NULL; return NULL;
return CefPostDataElementCppToC::Wrap(elements[elementIndex]); return CefPostDataElementCppToC::Wrap(elements[elementIndex]);
} }
int CEF_CALLBACK post_data_remove_element(struct _cef_post_data_t* self, int CEF_CALLBACK post_data_remove_element(struct _cef_post_data_t* self,
struct _cef_post_data_element_t* element) struct _cef_post_data_element_t* element)
{ {
DCHECK(self); DCHECK(self);
DCHECK(element); DCHECK(element);
if(!self || !element) if(!self || !element)
return 0; return 0;
CefRefPtr<CefPostDataElement> selfElementPtr = CefRefPtr<CefPostDataElement> selfElementPtr =
CefPostDataElementCppToC::Unwrap(element); CefPostDataElementCppToC::Unwrap(element);
return CefPostDataCppToC::Get(self)->RemoveElement(selfElementPtr); return CefPostDataCppToC::Get(self)->RemoveElement(selfElementPtr);
} }
int CEF_CALLBACK post_data_add_element(struct _cef_post_data_t* self, int CEF_CALLBACK post_data_add_element(struct _cef_post_data_t* self,
struct _cef_post_data_element_t* element) struct _cef_post_data_element_t* element)
{ {
DCHECK(self); DCHECK(self);
DCHECK(element); DCHECK(element);
if(!self || !element) if(!self || !element)
return 0; return 0;
CefRefPtr<CefPostDataElement> selfElementPtr = CefRefPtr<CefPostDataElement> selfElementPtr =
CefPostDataElementCppToC::Unwrap(element); CefPostDataElementCppToC::Unwrap(element);
return CefPostDataCppToC::Get(self)->AddElement(selfElementPtr); return CefPostDataCppToC::Get(self)->AddElement(selfElementPtr);
} }
void CEF_CALLBACK post_data_remove_elements(struct _cef_post_data_t* self) void CEF_CALLBACK post_data_remove_elements(struct _cef_post_data_t* self)
{ {
DCHECK(self); DCHECK(self);
if(!self) if(!self)
return; return;
CefPostDataCppToC::Get(self)->RemoveElements(); CefPostDataCppToC::Get(self)->RemoveElements();
} }
// CONSTRUCTOR - Do not edit by hand. // CONSTRUCTOR - Do not edit by hand.
CefPostDataCppToC::CefPostDataCppToC(CefPostData* cls) CefPostDataCppToC::CefPostDataCppToC(CefPostData* cls)
: CefCppToC<CefPostDataCppToC, CefPostData, cef_post_data_t>(cls) : CefCppToC<CefPostDataCppToC, CefPostData, cef_post_data_t>(cls)
{ {
struct_.struct_.get_element_count = post_data_get_element_count; struct_.struct_.get_element_count = post_data_get_element_count;
struct_.struct_.get_elements = post_data_get_elements; struct_.struct_.get_elements = post_data_get_elements;
struct_.struct_.remove_element = post_data_remove_element; struct_.struct_.remove_element = post_data_remove_element;
struct_.struct_.add_element = post_data_add_element; struct_.struct_.add_element = post_data_add_element;
struct_.struct_.remove_elements = post_data_remove_elements; struct_.struct_.remove_elements = post_data_remove_elements;
} }
#ifdef _DEBUG #ifdef _DEBUG
long CefCppToC<CefPostDataCppToC, CefPostData, cef_post_data_t>::DebugObjCt = 0; long CefCppToC<CefPostDataCppToC, CefPostData, cef_post_data_t>::DebugObjCt = 0;
#endif #endif

View File

@ -1,34 +1,34 @@
// Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights // Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that // reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file. // can be found in the LICENSE file.
// //
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
// //
// This file was generated by the CEF translator tool and should not edited // 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 // by hand. See the translator.README.txt file in the tools directory for
// more information. // more information.
// //
#ifndef _POSTDATA_CPPTOC_H #ifndef _POSTDATA_CPPTOC_H
#define _POSTDATA_CPPTOC_H #define _POSTDATA_CPPTOC_H
#ifndef BUILDING_CEF_SHARED #ifndef BUILDING_CEF_SHARED
#pragma message("Warning: "__FILE__" may be accessed DLL-side only") #pragma message("Warning: "__FILE__" may be accessed DLL-side only")
#else // BUILDING_CEF_SHARED #else // BUILDING_CEF_SHARED
#include "include/cef.h" #include "include/cef.h"
#include "include/cef_capi.h" #include "include/cef_capi.h"
#include "libcef_dll/cpptoc/cpptoc.h" #include "libcef_dll/cpptoc/cpptoc.h"
// Wrap a C++ class with a C structure. // Wrap a C++ class with a C structure.
// This class may be instantiated and accessed DLL-side only. // This class may be instantiated and accessed DLL-side only.
class CefPostDataCppToC class CefPostDataCppToC
: public CefCppToC<CefPostDataCppToC, CefPostData, cef_post_data_t> : public CefCppToC<CefPostDataCppToC, CefPostData, cef_post_data_t>
{ {
public: public:
CefPostDataCppToC(CefPostData* cls); CefPostDataCppToC(CefPostData* cls);
virtual ~CefPostDataCppToC() {} virtual ~CefPostDataCppToC() {}
}; };
#endif // BUILDING_CEF_SHARED #endif // BUILDING_CEF_SHARED
#endif // _POSTDATA_CPPTOC_H #endif // _POSTDATA_CPPTOC_H

View File

@ -1,128 +1,128 @@
// Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights // Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that // reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file. // can be found in the LICENSE file.
// //
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
// //
// A portion of this file was generated by the CEF translator tool. When // A portion of this file was generated by the CEF translator tool. When
// making changes by hand only do so within the body of existing function // making changes by hand only do so within the body of existing function
// implementations. See the translator.README.txt file in the tools directory // implementations. See the translator.README.txt file in the tools directory
// for more information. // for more information.
// //
#include "libcef_dll/cpptoc/post_data_element_cpptoc.h" #include "libcef_dll/cpptoc/post_data_element_cpptoc.h"
// GLOBAL FUNCTIONS - Body may be edited by hand. // GLOBAL FUNCTIONS - Body may be edited by hand.
CEF_EXPORT cef_post_data_element_t* cef_post_data_element_create() CEF_EXPORT cef_post_data_element_t* cef_post_data_element_create()
{ {
CefRefPtr<CefPostDataElement> impl = CefRefPtr<CefPostDataElement> impl =
CefPostDataElement::CreatePostDataElement(); CefPostDataElement::CreatePostDataElement();
if(impl.get()) if(impl.get())
return CefPostDataElementCppToC::Wrap(impl); return CefPostDataElementCppToC::Wrap(impl);
return NULL; return NULL;
} }
// MEMBER FUNCTIONS - Body may be edited by hand. // MEMBER FUNCTIONS - Body may be edited by hand.
void CEF_CALLBACK post_data_element_set_to_empty( void CEF_CALLBACK post_data_element_set_to_empty(
struct _cef_post_data_element_t* self) struct _cef_post_data_element_t* self)
{ {
DCHECK(self); DCHECK(self);
if(!self) if(!self)
return; return;
CefPostDataElementCppToC::Get(self)->SetToEmpty(); CefPostDataElementCppToC::Get(self)->SetToEmpty();
} }
void CEF_CALLBACK post_data_element_set_to_file( void CEF_CALLBACK post_data_element_set_to_file(
struct _cef_post_data_element_t* self, const wchar_t* fileName) struct _cef_post_data_element_t* self, const wchar_t* fileName)
{ {
DCHECK(self); DCHECK(self);
if(!self) if(!self)
return; return;
std::wstring fileNameStr; std::wstring fileNameStr;
if(fileName) if(fileName)
fileNameStr = fileName; fileNameStr = fileName;
CefPostDataElementCppToC::Get(self)->SetToFile(fileNameStr); CefPostDataElementCppToC::Get(self)->SetToFile(fileNameStr);
} }
void CEF_CALLBACK post_data_element_set_to_bytes( void CEF_CALLBACK post_data_element_set_to_bytes(
struct _cef_post_data_element_t* self, size_t size, const void* bytes) struct _cef_post_data_element_t* self, size_t size, const void* bytes)
{ {
DCHECK(self); DCHECK(self);
if(!self) if(!self)
return; return;
CefPostDataElementCppToC::Get(self)->SetToBytes(size, bytes); CefPostDataElementCppToC::Get(self)->SetToBytes(size, bytes);
} }
enum cef_postdataelement_type_t CEF_CALLBACK post_data_element_get_type( enum cef_postdataelement_type_t CEF_CALLBACK post_data_element_get_type(
struct _cef_post_data_element_t* self) struct _cef_post_data_element_t* self)
{ {
DCHECK(self); DCHECK(self);
if(!self) if(!self)
return PDE_TYPE_EMPTY; return PDE_TYPE_EMPTY;
return CefPostDataElementCppToC::Get(self)->GetType(); return CefPostDataElementCppToC::Get(self)->GetType();
} }
cef_string_t CEF_CALLBACK post_data_element_get_file( cef_string_t CEF_CALLBACK post_data_element_get_file(
struct _cef_post_data_element_t* self) struct _cef_post_data_element_t* self)
{ {
DCHECK(self); DCHECK(self);
if(!self) if(!self)
return NULL; return NULL;
std::wstring fileNameStr = std::wstring fileNameStr =
CefPostDataElementCppToC::Get(self)->GetFile(); CefPostDataElementCppToC::Get(self)->GetFile();
if(!fileNameStr.empty()) if(!fileNameStr.empty())
return cef_string_alloc(fileNameStr.c_str()); return cef_string_alloc(fileNameStr.c_str());
return NULL; return NULL;
} }
size_t CEF_CALLBACK post_data_element_get_bytes_count( size_t CEF_CALLBACK post_data_element_get_bytes_count(
struct _cef_post_data_element_t* self) struct _cef_post_data_element_t* self)
{ {
DCHECK(self); DCHECK(self);
if(!self) if(!self)
return 0; return 0;
return CefPostDataElementCppToC::Get(self)->GetBytesCount(); return CefPostDataElementCppToC::Get(self)->GetBytesCount();
} }
size_t CEF_CALLBACK post_data_element_get_bytes( size_t CEF_CALLBACK post_data_element_get_bytes(
struct _cef_post_data_element_t* self, size_t size, void* bytes) struct _cef_post_data_element_t* self, size_t size, void* bytes)
{ {
DCHECK(self); DCHECK(self);
if(!self) if(!self)
return 0; return 0;
return CefPostDataElementCppToC::Get(self)->GetBytes(size, bytes); return CefPostDataElementCppToC::Get(self)->GetBytes(size, bytes);
} }
// CONSTRUCTOR - Do not edit by hand. // CONSTRUCTOR - Do not edit by hand.
CefPostDataElementCppToC::CefPostDataElementCppToC(CefPostDataElement* cls) CefPostDataElementCppToC::CefPostDataElementCppToC(CefPostDataElement* cls)
: CefCppToC<CefPostDataElementCppToC, CefPostDataElement, : CefCppToC<CefPostDataElementCppToC, CefPostDataElement,
cef_post_data_element_t>(cls) cef_post_data_element_t>(cls)
{ {
struct_.struct_.set_to_empty = post_data_element_set_to_empty; struct_.struct_.set_to_empty = post_data_element_set_to_empty;
struct_.struct_.set_to_file = post_data_element_set_to_file; struct_.struct_.set_to_file = post_data_element_set_to_file;
struct_.struct_.set_to_bytes = post_data_element_set_to_bytes; struct_.struct_.set_to_bytes = post_data_element_set_to_bytes;
struct_.struct_.get_type = post_data_element_get_type; struct_.struct_.get_type = post_data_element_get_type;
struct_.struct_.get_file = post_data_element_get_file; struct_.struct_.get_file = post_data_element_get_file;
struct_.struct_.get_bytes_count = post_data_element_get_bytes_count; struct_.struct_.get_bytes_count = post_data_element_get_bytes_count;
struct_.struct_.get_bytes = post_data_element_get_bytes; struct_.struct_.get_bytes = post_data_element_get_bytes;
} }
#ifdef _DEBUG #ifdef _DEBUG
long CefCppToC<CefPostDataElementCppToC, CefPostDataElement, long CefCppToC<CefPostDataElementCppToC, CefPostDataElement,
cef_post_data_element_t>::DebugObjCt = 0; cef_post_data_element_t>::DebugObjCt = 0;
#endif #endif

View File

@ -1,35 +1,35 @@
// Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights // Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that // reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file. // can be found in the LICENSE file.
// //
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
// //
// This file was generated by the CEF translator tool and should not edited // 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 // by hand. See the translator.README.txt file in the tools directory for
// more information. // more information.
// //
#ifndef _POSTDATAELEMENT_CPPTOC_H #ifndef _POSTDATAELEMENT_CPPTOC_H
#define _POSTDATAELEMENT_CPPTOC_H #define _POSTDATAELEMENT_CPPTOC_H
#ifndef BUILDING_CEF_SHARED #ifndef BUILDING_CEF_SHARED
#pragma message("Warning: "__FILE__" may be accessed DLL-side only") #pragma message("Warning: "__FILE__" may be accessed DLL-side only")
#else // BUILDING_CEF_SHARED #else // BUILDING_CEF_SHARED
#include "include/cef.h" #include "include/cef.h"
#include "include/cef_capi.h" #include "include/cef_capi.h"
#include "libcef_dll/cpptoc/cpptoc.h" #include "libcef_dll/cpptoc/cpptoc.h"
// Wrap a C++ class with a C structure. // Wrap a C++ class with a C structure.
// This class may be instantiated and accessed DLL-side only. // This class may be instantiated and accessed DLL-side only.
class CefPostDataElementCppToC class CefPostDataElementCppToC
: public CefCppToC<CefPostDataElementCppToC, CefPostDataElement, : public CefCppToC<CefPostDataElementCppToC, CefPostDataElement,
cef_post_data_element_t> cef_post_data_element_t>
{ {
public: public:
CefPostDataElementCppToC(CefPostDataElement* cls); CefPostDataElementCppToC(CefPostDataElement* cls);
virtual ~CefPostDataElementCppToC() {} virtual ~CefPostDataElementCppToC() {}
}; };
#endif // BUILDING_CEF_SHARED #endif // BUILDING_CEF_SHARED
#endif // _POSTDATAELEMENT_CPPTOC_H #endif // _POSTDATAELEMENT_CPPTOC_H

View File

@ -1,72 +1,72 @@
// Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights // Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that // reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file. // can be found in the LICENSE file.
// //
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
// //
// A portion of this file was generated by the CEF translator tool. When // A portion of this file was generated by the CEF translator tool. When
// making changes by hand only do so within the body of existing function // making changes by hand only do so within the body of existing function
// implementations. See the translator.README.txt file in the tools directory // implementations. See the translator.README.txt file in the tools directory
// for more information. // for more information.
// //
#include "libcef_dll/cpptoc/read_handler_cpptoc.h" #include "libcef_dll/cpptoc/read_handler_cpptoc.h"
// MEMBER FUNCTIONS - Body may be edited by hand. // MEMBER FUNCTIONS - Body may be edited by hand.
size_t CEF_CALLBACK read_handler_read(struct _cef_read_handler_t* self, size_t CEF_CALLBACK read_handler_read(struct _cef_read_handler_t* self,
void* ptr, size_t size, size_t n) void* ptr, size_t size, size_t n)
{ {
DCHECK(self); DCHECK(self);
if(!self) if(!self)
return 0; return 0;
return CefReadHandlerCppToC::Get(self)->Read(ptr, size, n); return CefReadHandlerCppToC::Get(self)->Read(ptr, size, n);
} }
int CEF_CALLBACK read_handler_seek(struct _cef_read_handler_t* self, int CEF_CALLBACK read_handler_seek(struct _cef_read_handler_t* self,
long offset, int whence) long offset, int whence)
{ {
DCHECK(self); DCHECK(self);
if(!self) if(!self)
return 0; return 0;
return CefReadHandlerCppToC::Get(self)->Seek(offset, whence); return CefReadHandlerCppToC::Get(self)->Seek(offset, whence);
} }
long CEF_CALLBACK read_handler_tell(struct _cef_read_handler_t* self) long CEF_CALLBACK read_handler_tell(struct _cef_read_handler_t* self)
{ {
DCHECK(self); DCHECK(self);
if(!self) if(!self)
return 0; return 0;
return CefReadHandlerCppToC::Get(self)->Tell(); return CefReadHandlerCppToC::Get(self)->Tell();
} }
int CEF_CALLBACK read_handler_eof(struct _cef_read_handler_t* self) int CEF_CALLBACK read_handler_eof(struct _cef_read_handler_t* self)
{ {
DCHECK(self); DCHECK(self);
if(!self) if(!self)
return 0; return 0;
return CefReadHandlerCppToC::Get(self)->Eof(); return CefReadHandlerCppToC::Get(self)->Eof();
} }
// CONSTRUCTOR - Do not edit by hand. // CONSTRUCTOR - Do not edit by hand.
CefReadHandlerCppToC::CefReadHandlerCppToC(CefReadHandler* cls) CefReadHandlerCppToC::CefReadHandlerCppToC(CefReadHandler* cls)
: CefCppToC<CefReadHandlerCppToC, CefReadHandler, cef_read_handler_t>(cls) : CefCppToC<CefReadHandlerCppToC, CefReadHandler, cef_read_handler_t>(cls)
{ {
struct_.struct_.read = read_handler_read; struct_.struct_.read = read_handler_read;
struct_.struct_.seek = read_handler_seek; struct_.struct_.seek = read_handler_seek;
struct_.struct_.tell = read_handler_tell; struct_.struct_.tell = read_handler_tell;
struct_.struct_.eof = read_handler_eof; struct_.struct_.eof = read_handler_eof;
} }
#ifdef _DEBUG #ifdef _DEBUG
long CefCppToC<CefReadHandlerCppToC, CefReadHandler, long CefCppToC<CefReadHandlerCppToC, CefReadHandler,
cef_read_handler_t>::DebugObjCt = 0; cef_read_handler_t>::DebugObjCt = 0;
#endif #endif

View File

@ -1,34 +1,34 @@
// Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights // Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that // reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file. // can be found in the LICENSE file.
// //
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
// //
// This file was generated by the CEF translator tool and should not edited // 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 // by hand. See the translator.README.txt file in the tools directory for
// more information. // more information.
// //
#ifndef _READHANDLER_CPPTOC_H #ifndef _READHANDLER_CPPTOC_H
#define _READHANDLER_CPPTOC_H #define _READHANDLER_CPPTOC_H
#ifndef USING_CEF_SHARED #ifndef USING_CEF_SHARED
#pragma message("Warning: "__FILE__" may be accessed wrapper-side only") #pragma message("Warning: "__FILE__" may be accessed wrapper-side only")
#else // USING_CEF_SHARED #else // USING_CEF_SHARED
#include "include/cef.h" #include "include/cef.h"
#include "include/cef_capi.h" #include "include/cef_capi.h"
#include "libcef_dll/cpptoc/cpptoc.h" #include "libcef_dll/cpptoc/cpptoc.h"
// Wrap a C++ class with a C structure. // Wrap a C++ class with a C structure.
// This class may be instantiated and accessed wrapper-side only. // This class may be instantiated and accessed wrapper-side only.
class CefReadHandlerCppToC class CefReadHandlerCppToC
: public CefCppToC<CefReadHandlerCppToC, CefReadHandler, cef_read_handler_t> : public CefCppToC<CefReadHandlerCppToC, CefReadHandler, cef_read_handler_t>
{ {
public: public:
CefReadHandlerCppToC(CefReadHandler* cls); CefReadHandlerCppToC(CefReadHandler* cls);
virtual ~CefReadHandlerCppToC() {} virtual ~CefReadHandlerCppToC() {}
}; };
#endif // USING_CEF_SHARED #endif // USING_CEF_SHARED
#endif // _READHANDLER_CPPTOC_H #endif // _READHANDLER_CPPTOC_H

View File

@ -1,180 +1,180 @@
// Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights // Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that // reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file. // can be found in the LICENSE file.
// //
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
// //
// A portion of this file was generated by the CEF translator tool. When // A portion of this file was generated by the CEF translator tool. When
// making changes by hand only do so within the body of existing function // making changes by hand only do so within the body of existing function
// implementations. See the translator.README.txt file in the tools directory // implementations. See the translator.README.txt file in the tools directory
// for more information. // for more information.
// //
#include "libcef_dll/cpptoc/post_data_cpptoc.h" #include "libcef_dll/cpptoc/post_data_cpptoc.h"
#include "libcef_dll/cpptoc/request_cpptoc.h" #include "libcef_dll/cpptoc/request_cpptoc.h"
#include "libcef_dll/transfer_util.h" #include "libcef_dll/transfer_util.h"
// GLOBAL FUNCTIONS - Body may be edited by hand. // GLOBAL FUNCTIONS - Body may be edited by hand.
CEF_EXPORT cef_request_t* cef_request_create() CEF_EXPORT cef_request_t* cef_request_create()
{ {
CefRefPtr<CefRequest> impl = CefRequest::CreateRequest(); CefRefPtr<CefRequest> impl = CefRequest::CreateRequest();
if(impl.get()) if(impl.get())
return CefRequestCppToC::Wrap(impl); return CefRequestCppToC::Wrap(impl);
return NULL; return NULL;
} }
// MEMBER FUNCTIONS - Body may be edited by hand. // MEMBER FUNCTIONS - Body may be edited by hand.
cef_string_t CEF_CALLBACK request_get_url(struct _cef_request_t* self) cef_string_t CEF_CALLBACK request_get_url(struct _cef_request_t* self)
{ {
DCHECK(self); DCHECK(self);
if(!self) if(!self)
return NULL; return NULL;
std::wstring urlStr = CefRequestCppToC::Get(self)->GetURL(); std::wstring urlStr = CefRequestCppToC::Get(self)->GetURL();
if(!urlStr.empty()) if(!urlStr.empty())
return cef_string_alloc(urlStr.c_str()); return cef_string_alloc(urlStr.c_str());
return NULL; return NULL;
} }
void CEF_CALLBACK request_set_url(struct _cef_request_t* self, void CEF_CALLBACK request_set_url(struct _cef_request_t* self,
const wchar_t* url) const wchar_t* url)
{ {
DCHECK(self); DCHECK(self);
if(!self) if(!self)
return; return;
std::wstring urlStr; std::wstring urlStr;
if(url) if(url)
urlStr = url; urlStr = url;
CefRequestCppToC::Get(self)->SetURL(urlStr); CefRequestCppToC::Get(self)->SetURL(urlStr);
} }
cef_string_t CEF_CALLBACK request_get_method(struct _cef_request_t* self) cef_string_t CEF_CALLBACK request_get_method(struct _cef_request_t* self)
{ {
DCHECK(self); DCHECK(self);
if(!self) if(!self)
return NULL; return NULL;
std::wstring methodStr = CefRequestCppToC::Get(self)->GetMethod(); std::wstring methodStr = CefRequestCppToC::Get(self)->GetMethod();
if(!methodStr.empty()) if(!methodStr.empty())
return cef_string_alloc(methodStr.c_str()); return cef_string_alloc(methodStr.c_str());
return NULL; return NULL;
} }
void CEF_CALLBACK request_set_method(struct _cef_request_t* self, void CEF_CALLBACK request_set_method(struct _cef_request_t* self,
const wchar_t* method) const wchar_t* method)
{ {
DCHECK(self); DCHECK(self);
if(!self) if(!self)
return; return;
std::wstring methodStr; std::wstring methodStr;
if(method) if(method)
methodStr = method; methodStr = method;
CefRequestCppToC::Get(self)->SetMethod(methodStr); CefRequestCppToC::Get(self)->SetMethod(methodStr);
} }
struct _cef_post_data_t* CEF_CALLBACK request_get_post_data( struct _cef_post_data_t* CEF_CALLBACK request_get_post_data(
struct _cef_request_t* self) struct _cef_request_t* self)
{ {
DCHECK(self); DCHECK(self);
if(!self) if(!self)
return NULL; return NULL;
CefRefPtr<CefPostData> postDataPtr = CefRefPtr<CefPostData> postDataPtr =
CefRequestCppToC::Get(self)->GetPostData(); CefRequestCppToC::Get(self)->GetPostData();
if(!postDataPtr.get()) if(!postDataPtr.get())
return NULL; return NULL;
return CefPostDataCppToC::Wrap(postDataPtr); return CefPostDataCppToC::Wrap(postDataPtr);
} }
void CEF_CALLBACK request_set_post_data(struct _cef_request_t* self, void CEF_CALLBACK request_set_post_data(struct _cef_request_t* self,
struct _cef_post_data_t* postData) struct _cef_post_data_t* postData)
{ {
DCHECK(self); DCHECK(self);
if(!self) if(!self)
return; return;
CefRefPtr<CefPostData> postDataPtr; CefRefPtr<CefPostData> postDataPtr;
if(postData) if(postData)
postDataPtr = CefPostDataCppToC::Unwrap(postData); postDataPtr = CefPostDataCppToC::Unwrap(postData);
CefRequestCppToC::Get(self)->SetPostData(postDataPtr); CefRequestCppToC::Get(self)->SetPostData(postDataPtr);
} }
void CEF_CALLBACK request_get_header_map(struct _cef_request_t* self, void CEF_CALLBACK request_get_header_map(struct _cef_request_t* self,
cef_string_map_t headerMap) cef_string_map_t headerMap)
{ {
DCHECK(self); DCHECK(self);
if(!self) if(!self)
return; return;
CefRequest::HeaderMap map; CefRequest::HeaderMap map;
CefRequestCppToC::Get(self)->GetHeaderMap(map); CefRequestCppToC::Get(self)->GetHeaderMap(map);
transfer_string_map_contents(map, headerMap); transfer_string_map_contents(map, headerMap);
} }
void CEF_CALLBACK request_set_header_map(struct _cef_request_t* self, void CEF_CALLBACK request_set_header_map(struct _cef_request_t* self,
cef_string_map_t headerMap) cef_string_map_t headerMap)
{ {
DCHECK(self); DCHECK(self);
if(!self) if(!self)
return; return;
CefRequest::HeaderMap map; CefRequest::HeaderMap map;
if(headerMap) if(headerMap)
transfer_string_map_contents(headerMap, map); transfer_string_map_contents(headerMap, map);
CefRequestCppToC::Get(self)->SetHeaderMap(map); CefRequestCppToC::Get(self)->SetHeaderMap(map);
} }
void CEF_CALLBACK request_set(struct _cef_request_t* self, const wchar_t* url, void CEF_CALLBACK request_set(struct _cef_request_t* self, const wchar_t* url,
const wchar_t* method, struct _cef_post_data_t* postData, const wchar_t* method, struct _cef_post_data_t* postData,
cef_string_map_t headerMap) cef_string_map_t headerMap)
{ {
DCHECK(self); DCHECK(self);
if(!self) if(!self)
return; return;
std::wstring urlStr, methodStr; std::wstring urlStr, methodStr;
CefRefPtr<CefPostData> postDataPtr; CefRefPtr<CefPostData> postDataPtr;
CefRequest::HeaderMap map; CefRequest::HeaderMap map;
if(url) if(url)
urlStr = url; urlStr = url;
if(method) if(method)
methodStr = method; methodStr = method;
if(postData) if(postData)
postDataPtr = CefPostDataCppToC::Unwrap(postData); postDataPtr = CefPostDataCppToC::Unwrap(postData);
if(headerMap) if(headerMap)
transfer_string_map_contents(headerMap, map); transfer_string_map_contents(headerMap, map);
CefRequestCppToC::Get(self)->Set(urlStr, methodStr, postDataPtr, map); CefRequestCppToC::Get(self)->Set(urlStr, methodStr, postDataPtr, map);
} }
// CONSTRUCTOR - Do not edit by hand. // CONSTRUCTOR - Do not edit by hand.
CefRequestCppToC::CefRequestCppToC(CefRequest* cls) CefRequestCppToC::CefRequestCppToC(CefRequest* cls)
: CefCppToC<CefRequestCppToC, CefRequest, cef_request_t>(cls) : CefCppToC<CefRequestCppToC, CefRequest, cef_request_t>(cls)
{ {
struct_.struct_.get_url = request_get_url; struct_.struct_.get_url = request_get_url;
struct_.struct_.set_url = request_set_url; struct_.struct_.set_url = request_set_url;
struct_.struct_.get_method = request_get_method; struct_.struct_.get_method = request_get_method;
struct_.struct_.set_method = request_set_method; struct_.struct_.set_method = request_set_method;
struct_.struct_.get_post_data = request_get_post_data; struct_.struct_.get_post_data = request_get_post_data;
struct_.struct_.set_post_data = request_set_post_data; struct_.struct_.set_post_data = request_set_post_data;
struct_.struct_.get_header_map = request_get_header_map; struct_.struct_.get_header_map = request_get_header_map;
struct_.struct_.set_header_map = request_set_header_map; struct_.struct_.set_header_map = request_set_header_map;
struct_.struct_.set = request_set; struct_.struct_.set = request_set;
} }
#ifdef _DEBUG #ifdef _DEBUG
long CefCppToC<CefRequestCppToC, CefRequest, cef_request_t>::DebugObjCt = 0; long CefCppToC<CefRequestCppToC, CefRequest, cef_request_t>::DebugObjCt = 0;
#endif #endif

View File

@ -1,34 +1,34 @@
// Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights // Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that // reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file. // can be found in the LICENSE file.
// //
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
// //
// This file was generated by the CEF translator tool and should not edited // 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 // by hand. See the translator.README.txt file in the tools directory for
// more information. // more information.
// //
#ifndef _REQUEST_CPPTOC_H #ifndef _REQUEST_CPPTOC_H
#define _REQUEST_CPPTOC_H #define _REQUEST_CPPTOC_H
#ifndef BUILDING_CEF_SHARED #ifndef BUILDING_CEF_SHARED
#pragma message("Warning: "__FILE__" may be accessed DLL-side only") #pragma message("Warning: "__FILE__" may be accessed DLL-side only")
#else // BUILDING_CEF_SHARED #else // BUILDING_CEF_SHARED
#include "include/cef.h" #include "include/cef.h"
#include "include/cef_capi.h" #include "include/cef_capi.h"
#include "libcef_dll/cpptoc/cpptoc.h" #include "libcef_dll/cpptoc/cpptoc.h"
// Wrap a C++ class with a C structure. // Wrap a C++ class with a C structure.
// This class may be instantiated and accessed DLL-side only. // This class may be instantiated and accessed DLL-side only.
class CefRequestCppToC class CefRequestCppToC
: public CefCppToC<CefRequestCppToC, CefRequest, cef_request_t> : public CefCppToC<CefRequestCppToC, CefRequest, cef_request_t>
{ {
public: public:
CefRequestCppToC(CefRequest* cls); CefRequestCppToC(CefRequest* cls);
virtual ~CefRequestCppToC() {} virtual ~CefRequestCppToC() {}
}; };
#endif // BUILDING_CEF_SHARED #endif // BUILDING_CEF_SHARED
#endif // _REQUEST_CPPTOC_H #endif // _REQUEST_CPPTOC_H

View File

@ -1,84 +1,84 @@
// Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights // Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that // reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file. // can be found in the LICENSE file.
// //
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
// //
// A portion of this file was generated by the CEF translator tool. When // A portion of this file was generated by the CEF translator tool. When
// making changes by hand only do so within the body of existing function // making changes by hand only do so within the body of existing function
// implementations. See the translator.README.txt file in the tools directory // implementations. See the translator.README.txt file in the tools directory
// for more information. // for more information.
// //
#include "libcef_dll/cpptoc/scheme_handler_cpptoc.h" #include "libcef_dll/cpptoc/scheme_handler_cpptoc.h"
#include "libcef_dll/ctocpp/request_ctocpp.h" #include "libcef_dll/ctocpp/request_ctocpp.h"
#include "libcef_dll/transfer_util.h" #include "libcef_dll/transfer_util.h"
// MEMBER FUNCTIONS - Body may be edited by hand. // MEMBER FUNCTIONS - Body may be edited by hand.
int CEF_CALLBACK scheme_handler_process_request( int CEF_CALLBACK scheme_handler_process_request(
struct _cef_scheme_handler_t* self, cef_request_t* request, struct _cef_scheme_handler_t* self, cef_request_t* request,
cef_string_t* mime_type, int* response_length) cef_string_t* mime_type, int* response_length)
{ {
DCHECK(self); DCHECK(self);
DCHECK(request); DCHECK(request);
DCHECK(mime_type); DCHECK(mime_type);
DCHECK(response_length); DCHECK(response_length);
if(!self || !request || !mime_type || !response_length) if(!self || !request || !mime_type || !response_length)
return 0; return 0;
std::wstring mimeTypeStr; std::wstring mimeTypeStr;
if(*mime_type) if(*mime_type)
mimeTypeStr = *mime_type; mimeTypeStr = *mime_type;
bool rv = CefSchemeHandlerCppToC::Get(self)->ProcessRequest( bool rv = CefSchemeHandlerCppToC::Get(self)->ProcessRequest(
CefRequestCToCpp::Wrap(request), mimeTypeStr, response_length); CefRequestCToCpp::Wrap(request), mimeTypeStr, response_length);
transfer_string_contents(mimeTypeStr, mime_type); transfer_string_contents(mimeTypeStr, mime_type);
return rv?1:0; return rv?1:0;
} }
void CEF_CALLBACK scheme_handler_cancel(struct _cef_scheme_handler_t* self) void CEF_CALLBACK scheme_handler_cancel(struct _cef_scheme_handler_t* self)
{ {
DCHECK(self); DCHECK(self);
if(!self) if(!self)
return; return;
CefSchemeHandlerCppToC::Get(self)->Cancel(); CefSchemeHandlerCppToC::Get(self)->Cancel();
} }
int CEF_CALLBACK scheme_handler_read_response( int CEF_CALLBACK scheme_handler_read_response(
struct _cef_scheme_handler_t* self, void* data_out, int bytes_to_read, struct _cef_scheme_handler_t* self, void* data_out, int bytes_to_read,
int* bytes_read) int* bytes_read)
{ {
DCHECK(self); DCHECK(self);
DCHECK(data_out); DCHECK(data_out);
DCHECK(bytes_read); DCHECK(bytes_read);
if(!self || !data_out || !bytes_read) if(!self || !data_out || !bytes_read)
return 0; return 0;
bool rv = CefSchemeHandlerCppToC::Get(self)->ReadResponse( bool rv = CefSchemeHandlerCppToC::Get(self)->ReadResponse(
data_out, bytes_to_read, bytes_read); data_out, bytes_to_read, bytes_read);
return rv?1:0; return rv?1:0;
} }
// CONSTRUCTOR - Do not edit by hand. // CONSTRUCTOR - Do not edit by hand.
CefSchemeHandlerCppToC::CefSchemeHandlerCppToC(CefSchemeHandler* cls) CefSchemeHandlerCppToC::CefSchemeHandlerCppToC(CefSchemeHandler* cls)
: CefCppToC<CefSchemeHandlerCppToC, CefSchemeHandler, cef_scheme_handler_t>( : CefCppToC<CefSchemeHandlerCppToC, CefSchemeHandler, cef_scheme_handler_t>(
cls) cls)
{ {
struct_.struct_.process_request = scheme_handler_process_request; struct_.struct_.process_request = scheme_handler_process_request;
struct_.struct_.cancel = scheme_handler_cancel; struct_.struct_.cancel = scheme_handler_cancel;
struct_.struct_.read_response = scheme_handler_read_response; struct_.struct_.read_response = scheme_handler_read_response;
} }
#ifdef _DEBUG #ifdef _DEBUG
long CefCppToC<CefSchemeHandlerCppToC, CefSchemeHandler, long CefCppToC<CefSchemeHandlerCppToC, CefSchemeHandler,
cef_scheme_handler_t>::DebugObjCt = 0; cef_scheme_handler_t>::DebugObjCt = 0;
#endif #endif

View File

@ -1,35 +1,35 @@
// Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights // Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that // reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file. // can be found in the LICENSE file.
// //
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
// //
// This file was generated by the CEF translator tool and should not edited // 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 // by hand. See the translator.README.txt file in the tools directory for
// more information. // more information.
// //
#ifndef _SCHEMEHANDLER_CPPTOC_H #ifndef _SCHEMEHANDLER_CPPTOC_H
#define _SCHEMEHANDLER_CPPTOC_H #define _SCHEMEHANDLER_CPPTOC_H
#ifndef USING_CEF_SHARED #ifndef USING_CEF_SHARED
#pragma message("Warning: "__FILE__" may be accessed wrapper-side only") #pragma message("Warning: "__FILE__" may be accessed wrapper-side only")
#else // USING_CEF_SHARED #else // USING_CEF_SHARED
#include "include/cef.h" #include "include/cef.h"
#include "include/cef_capi.h" #include "include/cef_capi.h"
#include "libcef_dll/cpptoc/cpptoc.h" #include "libcef_dll/cpptoc/cpptoc.h"
// Wrap a C++ class with a C structure. // Wrap a C++ class with a C structure.
// This class may be instantiated and accessed wrapper-side only. // This class may be instantiated and accessed wrapper-side only.
class CefSchemeHandlerCppToC class CefSchemeHandlerCppToC
: public CefCppToC<CefSchemeHandlerCppToC, CefSchemeHandler, : public CefCppToC<CefSchemeHandlerCppToC, CefSchemeHandler,
cef_scheme_handler_t> cef_scheme_handler_t>
{ {
public: public:
CefSchemeHandlerCppToC(CefSchemeHandler* cls); CefSchemeHandlerCppToC(CefSchemeHandler* cls);
virtual ~CefSchemeHandlerCppToC() {} virtual ~CefSchemeHandlerCppToC() {}
}; };
#endif // USING_CEF_SHARED #endif // USING_CEF_SHARED
#endif // _SCHEMEHANDLER_CPPTOC_H #endif // _SCHEMEHANDLER_CPPTOC_H

View File

@ -1,43 +1,43 @@
// Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights // Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that // reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file. // can be found in the LICENSE file.
// //
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
// //
// A portion of this file was generated by the CEF translator tool. When // A portion of this file was generated by the CEF translator tool. When
// making changes by hand only do so within the body of existing function // making changes by hand only do so within the body of existing function
// implementations. See the translator.README.txt file in the tools directory // implementations. See the translator.README.txt file in the tools directory
// for more information. // for more information.
// //
#include "libcef_dll/cpptoc/scheme_handler_cpptoc.h" #include "libcef_dll/cpptoc/scheme_handler_cpptoc.h"
#include "libcef_dll/cpptoc/scheme_handler_factory_cpptoc.h" #include "libcef_dll/cpptoc/scheme_handler_factory_cpptoc.h"
// MEMBER FUNCTIONS - Body may be edited by hand. // MEMBER FUNCTIONS - Body may be edited by hand.
struct _cef_scheme_handler_t* CEF_CALLBACK scheme_handler_factory_create( struct _cef_scheme_handler_t* CEF_CALLBACK scheme_handler_factory_create(
struct _cef_scheme_handler_factory_t* self) struct _cef_scheme_handler_factory_t* self)
{ {
CefRefPtr<CefSchemeHandler> rv = CefRefPtr<CefSchemeHandler> rv =
CefSchemeHandlerFactoryCppToC::Get(self)->Create(); CefSchemeHandlerFactoryCppToC::Get(self)->Create();
return CefSchemeHandlerCppToC::Wrap(rv); return CefSchemeHandlerCppToC::Wrap(rv);
} }
// CONSTRUCTOR - Do not edit by hand. // CONSTRUCTOR - Do not edit by hand.
CefSchemeHandlerFactoryCppToC::CefSchemeHandlerFactoryCppToC( CefSchemeHandlerFactoryCppToC::CefSchemeHandlerFactoryCppToC(
CefSchemeHandlerFactory* cls) CefSchemeHandlerFactory* cls)
: CefCppToC<CefSchemeHandlerFactoryCppToC, CefSchemeHandlerFactory, : CefCppToC<CefSchemeHandlerFactoryCppToC, CefSchemeHandlerFactory,
cef_scheme_handler_factory_t>(cls) cef_scheme_handler_factory_t>(cls)
{ {
struct_.struct_.create = scheme_handler_factory_create; struct_.struct_.create = scheme_handler_factory_create;
} }
#ifdef _DEBUG #ifdef _DEBUG
long CefCppToC<CefSchemeHandlerFactoryCppToC, CefSchemeHandlerFactory, long CefCppToC<CefSchemeHandlerFactoryCppToC, CefSchemeHandlerFactory,
cef_scheme_handler_factory_t>::DebugObjCt = 0; cef_scheme_handler_factory_t>::DebugObjCt = 0;
#endif #endif

View File

@ -1,35 +1,35 @@
// Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights // Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that // reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file. // can be found in the LICENSE file.
// //
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
// //
// This file was generated by the CEF translator tool and should not edited // 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 // by hand. See the translator.README.txt file in the tools directory for
// more information. // more information.
// //
#ifndef _SCHEMEHANDLERFACTORY_CPPTOC_H #ifndef _SCHEMEHANDLERFACTORY_CPPTOC_H
#define _SCHEMEHANDLERFACTORY_CPPTOC_H #define _SCHEMEHANDLERFACTORY_CPPTOC_H
#ifndef USING_CEF_SHARED #ifndef USING_CEF_SHARED
#pragma message("Warning: "__FILE__" may be accessed wrapper-side only") #pragma message("Warning: "__FILE__" may be accessed wrapper-side only")
#else // USING_CEF_SHARED #else // USING_CEF_SHARED
#include "include/cef.h" #include "include/cef.h"
#include "include/cef_capi.h" #include "include/cef_capi.h"
#include "libcef_dll/cpptoc/cpptoc.h" #include "libcef_dll/cpptoc/cpptoc.h"
// Wrap a C++ class with a C structure. // Wrap a C++ class with a C structure.
// This class may be instantiated and accessed wrapper-side only. // This class may be instantiated and accessed wrapper-side only.
class CefSchemeHandlerFactoryCppToC class CefSchemeHandlerFactoryCppToC
: public CefCppToC<CefSchemeHandlerFactoryCppToC, CefSchemeHandlerFactory, : public CefCppToC<CefSchemeHandlerFactoryCppToC, CefSchemeHandlerFactory,
cef_scheme_handler_factory_t> cef_scheme_handler_factory_t>
{ {
public: public:
CefSchemeHandlerFactoryCppToC(CefSchemeHandlerFactory* cls); CefSchemeHandlerFactoryCppToC(CefSchemeHandlerFactory* cls);
virtual ~CefSchemeHandlerFactoryCppToC() {} virtual ~CefSchemeHandlerFactoryCppToC() {}
}; };
#endif // USING_CEF_SHARED #endif // USING_CEF_SHARED
#endif // _SCHEMEHANDLERFACTORY_CPPTOC_H #endif // _SCHEMEHANDLERFACTORY_CPPTOC_H

View File

@ -1,108 +1,108 @@
// Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights // Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that // reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file. // can be found in the LICENSE file.
// //
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
// //
// A portion of this file was generated by the CEF translator tool. When // A portion of this file was generated by the CEF translator tool. When
// making changes by hand only do so within the body of existing function // making changes by hand only do so within the body of existing function
// implementations. See the translator.README.txt file in the tools directory // implementations. See the translator.README.txt file in the tools directory
// for more information. // for more information.
// //
#include "libcef_dll/cpptoc/stream_reader_cpptoc.h" #include "libcef_dll/cpptoc/stream_reader_cpptoc.h"
#include "libcef_dll/ctocpp/read_handler_ctocpp.h" #include "libcef_dll/ctocpp/read_handler_ctocpp.h"
// GLOBAL FUNCTIONS - Body may be edited by hand. // GLOBAL FUNCTIONS - Body may be edited by hand.
CEF_EXPORT cef_stream_reader_t* cef_stream_reader_create_for_file( CEF_EXPORT cef_stream_reader_t* cef_stream_reader_create_for_file(
const wchar_t* fileName) const wchar_t* fileName)
{ {
std::wstring filenamestr; std::wstring filenamestr;
if(fileName) if(fileName)
filenamestr = fileName; filenamestr = fileName;
CefRefPtr<CefStreamReader> impl = CefStreamReader::CreateForFile(filenamestr); CefRefPtr<CefStreamReader> impl = CefStreamReader::CreateForFile(filenamestr);
if(impl.get()) if(impl.get())
return CefStreamReaderCppToC::Wrap(impl); return CefStreamReaderCppToC::Wrap(impl);
return NULL; return NULL;
} }
CEF_EXPORT cef_stream_reader_t* cef_stream_reader_create_for_data(void* data, CEF_EXPORT cef_stream_reader_t* cef_stream_reader_create_for_data(void* data,
size_t size) size_t size)
{ {
CefRefPtr<CefStreamReader> impl = CefStreamReader::CreateForData(data, size); CefRefPtr<CefStreamReader> impl = CefStreamReader::CreateForData(data, size);
if(impl.get()) if(impl.get())
return CefStreamReaderCppToC::Wrap(impl); return CefStreamReaderCppToC::Wrap(impl);
return NULL; return NULL;
} }
CEF_EXPORT cef_stream_reader_t* cef_stream_reader_create_for_handler( CEF_EXPORT cef_stream_reader_t* cef_stream_reader_create_for_handler(
cef_read_handler_t* handler) cef_read_handler_t* handler)
{ {
CefRefPtr<CefStreamReader> impl = CefRefPtr<CefStreamReader> impl =
CefStreamReader::CreateForHandler(CefReadHandlerCToCpp::Wrap(handler)); CefStreamReader::CreateForHandler(CefReadHandlerCToCpp::Wrap(handler));
if(impl.get()) if(impl.get())
return CefStreamReaderCppToC::Wrap(impl); return CefStreamReaderCppToC::Wrap(impl);
return NULL; return NULL;
} }
// MEMBER FUNCTIONS - Body may be edited by hand. // MEMBER FUNCTIONS - Body may be edited by hand.
size_t CEF_CALLBACK stream_reader_read(struct _cef_stream_reader_t* self, size_t CEF_CALLBACK stream_reader_read(struct _cef_stream_reader_t* self,
void* ptr, size_t size, size_t n) void* ptr, size_t size, size_t n)
{ {
DCHECK(self); DCHECK(self);
if(!self) if(!self)
return 0; return 0;
return CefStreamReaderCppToC::Get(self)->Read(ptr, size, n); return CefStreamReaderCppToC::Get(self)->Read(ptr, size, n);
} }
int CEF_CALLBACK stream_reader_seek(struct _cef_stream_reader_t* self, int CEF_CALLBACK stream_reader_seek(struct _cef_stream_reader_t* self,
long offset, int whence) long offset, int whence)
{ {
DCHECK(self); DCHECK(self);
if(!self) if(!self)
return 0; return 0;
return CefStreamReaderCppToC::Get(self)->Seek(offset, whence); return CefStreamReaderCppToC::Get(self)->Seek(offset, whence);
} }
long CEF_CALLBACK stream_reader_tell(struct _cef_stream_reader_t* self) long CEF_CALLBACK stream_reader_tell(struct _cef_stream_reader_t* self)
{ {
DCHECK(self); DCHECK(self);
if(!self) if(!self)
return 0; return 0;
return CefStreamReaderCppToC::Get(self)->Tell(); return CefStreamReaderCppToC::Get(self)->Tell();
} }
int CEF_CALLBACK stream_reader_eof(struct _cef_stream_reader_t* self) int CEF_CALLBACK stream_reader_eof(struct _cef_stream_reader_t* self)
{ {
DCHECK(self); DCHECK(self);
if(!self) if(!self)
return 0; return 0;
return CefStreamReaderCppToC::Get(self)->Eof(); return CefStreamReaderCppToC::Get(self)->Eof();
} }
// CONSTRUCTOR - Do not edit by hand. // CONSTRUCTOR - Do not edit by hand.
CefStreamReaderCppToC::CefStreamReaderCppToC(CefStreamReader* cls) CefStreamReaderCppToC::CefStreamReaderCppToC(CefStreamReader* cls)
: CefCppToC<CefStreamReaderCppToC, CefStreamReader, cef_stream_reader_t>( : CefCppToC<CefStreamReaderCppToC, CefStreamReader, cef_stream_reader_t>(
cls) cls)
{ {
struct_.struct_.read = stream_reader_read; struct_.struct_.read = stream_reader_read;
struct_.struct_.seek = stream_reader_seek; struct_.struct_.seek = stream_reader_seek;
struct_.struct_.tell = stream_reader_tell; struct_.struct_.tell = stream_reader_tell;
struct_.struct_.eof = stream_reader_eof; struct_.struct_.eof = stream_reader_eof;
} }
#ifdef _DEBUG #ifdef _DEBUG
long CefCppToC<CefStreamReaderCppToC, CefStreamReader, long CefCppToC<CefStreamReaderCppToC, CefStreamReader,
cef_stream_reader_t>::DebugObjCt = 0; cef_stream_reader_t>::DebugObjCt = 0;
#endif #endif

View File

@ -1,35 +1,35 @@
// Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights // Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that // reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file. // can be found in the LICENSE file.
// //
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
// //
// This file was generated by the CEF translator tool and should not edited // 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 // by hand. See the translator.README.txt file in the tools directory for
// more information. // more information.
// //
#ifndef _STREAMREADER_CPPTOC_H #ifndef _STREAMREADER_CPPTOC_H
#define _STREAMREADER_CPPTOC_H #define _STREAMREADER_CPPTOC_H
#ifndef BUILDING_CEF_SHARED #ifndef BUILDING_CEF_SHARED
#pragma message("Warning: "__FILE__" may be accessed DLL-side only") #pragma message("Warning: "__FILE__" may be accessed DLL-side only")
#else // BUILDING_CEF_SHARED #else // BUILDING_CEF_SHARED
#include "include/cef.h" #include "include/cef.h"
#include "include/cef_capi.h" #include "include/cef_capi.h"
#include "libcef_dll/cpptoc/cpptoc.h" #include "libcef_dll/cpptoc/cpptoc.h"
// Wrap a C++ class with a C structure. // Wrap a C++ class with a C structure.
// This class may be instantiated and accessed DLL-side only. // This class may be instantiated and accessed DLL-side only.
class CefStreamReaderCppToC class CefStreamReaderCppToC
: public CefCppToC<CefStreamReaderCppToC, CefStreamReader, : public CefCppToC<CefStreamReaderCppToC, CefStreamReader,
cef_stream_reader_t> cef_stream_reader_t>
{ {
public: public:
CefStreamReaderCppToC(CefStreamReader* cls); CefStreamReaderCppToC(CefStreamReader* cls);
virtual ~CefStreamReaderCppToC() {} virtual ~CefStreamReaderCppToC() {}
}; };
#endif // BUILDING_CEF_SHARED #endif // BUILDING_CEF_SHARED
#endif // _STREAMREADER_CPPTOC_H #endif // _STREAMREADER_CPPTOC_H

View File

@ -1,105 +1,105 @@
// Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights // Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that // reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file. // can be found in the LICENSE file.
// //
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
// //
// A portion of this file was generated by the CEF translator tool. When // A portion of this file was generated by the CEF translator tool. When
// making changes by hand only do so within the body of existing function // making changes by hand only do so within the body of existing function
// implementations. See the translator.README.txt file in the tools directory // implementations. See the translator.README.txt file in the tools directory
// for more information. // for more information.
// //
#include "libcef_dll/cpptoc/stream_writer_cpptoc.h" #include "libcef_dll/cpptoc/stream_writer_cpptoc.h"
#include "libcef_dll/ctocpp/write_handler_ctocpp.h" #include "libcef_dll/ctocpp/write_handler_ctocpp.h"
// GLOBAL FUNCTIONS - Body may be edited by hand. // GLOBAL FUNCTIONS - Body may be edited by hand.
CEF_EXPORT cef_stream_writer_t* cef_stream_writer_create_for_file( CEF_EXPORT cef_stream_writer_t* cef_stream_writer_create_for_file(
const wchar_t* fileName) const wchar_t* fileName)
{ {
DCHECK(fileName); DCHECK(fileName);
if(!fileName) if(!fileName)
return NULL; return NULL;
std::wstring fileNameStr = fileName; std::wstring fileNameStr = fileName;
CefRefPtr<CefStreamWriter> impl = CefStreamWriter::CreateForFile(fileName); CefRefPtr<CefStreamWriter> impl = CefStreamWriter::CreateForFile(fileName);
if(impl.get()) if(impl.get())
return CefStreamWriterCppToC::Wrap(impl); return CefStreamWriterCppToC::Wrap(impl);
return NULL; return NULL;
} }
CEF_EXPORT cef_stream_writer_t* cef_stream_writer_create_for_handler( CEF_EXPORT cef_stream_writer_t* cef_stream_writer_create_for_handler(
cef_write_handler_t* handler) cef_write_handler_t* handler)
{ {
DCHECK(handler); DCHECK(handler);
if(!handler) if(!handler)
return NULL; return NULL;
CefRefPtr<CefStreamWriter> impl = CefRefPtr<CefStreamWriter> impl =
CefStreamWriter::CreateForHandler(CefWriteHandlerCToCpp::Wrap(handler)); CefStreamWriter::CreateForHandler(CefWriteHandlerCToCpp::Wrap(handler));
if(impl.get()) if(impl.get())
return CefStreamWriterCppToC::Wrap(impl); return CefStreamWriterCppToC::Wrap(impl);
return NULL; return NULL;
} }
// MEMBER FUNCTIONS - Body may be edited by hand. // MEMBER FUNCTIONS - Body may be edited by hand.
size_t CEF_CALLBACK stream_writer_write(struct _cef_stream_writer_t* self, size_t CEF_CALLBACK stream_writer_write(struct _cef_stream_writer_t* self,
const void* ptr, size_t size, size_t n) const void* ptr, size_t size, size_t n)
{ {
DCHECK(self); DCHECK(self);
if(!self) if(!self)
return 0; return 0;
return CefStreamWriterCppToC::Get(self)->Write(ptr, size, n); return CefStreamWriterCppToC::Get(self)->Write(ptr, size, n);
} }
int CEF_CALLBACK stream_writer_seek(struct _cef_stream_writer_t* self, int CEF_CALLBACK stream_writer_seek(struct _cef_stream_writer_t* self,
long offset, int whence) long offset, int whence)
{ {
DCHECK(self); DCHECK(self);
if(!self) if(!self)
return 0; return 0;
return CefStreamWriterCppToC::Get(self)->Seek(offset, whence); return CefStreamWriterCppToC::Get(self)->Seek(offset, whence);
} }
long CEF_CALLBACK stream_writer_tell(struct _cef_stream_writer_t* self) long CEF_CALLBACK stream_writer_tell(struct _cef_stream_writer_t* self)
{ {
DCHECK(self); DCHECK(self);
if(!self) if(!self)
return 0; return 0;
return CefStreamWriterCppToC::Get(self)->Tell(); return CefStreamWriterCppToC::Get(self)->Tell();
} }
int CEF_CALLBACK stream_writer_flush(struct _cef_stream_writer_t* self) int CEF_CALLBACK stream_writer_flush(struct _cef_stream_writer_t* self)
{ {
DCHECK(self); DCHECK(self);
if(!self) if(!self)
return 0; return 0;
return CefStreamWriterCppToC::Get(self)->Flush(); return CefStreamWriterCppToC::Get(self)->Flush();
} }
// CONSTRUCTOR - Do not edit by hand. // CONSTRUCTOR - Do not edit by hand.
CefStreamWriterCppToC::CefStreamWriterCppToC(CefStreamWriter* cls) CefStreamWriterCppToC::CefStreamWriterCppToC(CefStreamWriter* cls)
: CefCppToC<CefStreamWriterCppToC, CefStreamWriter, cef_stream_writer_t>( : CefCppToC<CefStreamWriterCppToC, CefStreamWriter, cef_stream_writer_t>(
cls) cls)
{ {
struct_.struct_.write = stream_writer_write; struct_.struct_.write = stream_writer_write;
struct_.struct_.seek = stream_writer_seek; struct_.struct_.seek = stream_writer_seek;
struct_.struct_.tell = stream_writer_tell; struct_.struct_.tell = stream_writer_tell;
struct_.struct_.flush = stream_writer_flush; struct_.struct_.flush = stream_writer_flush;
} }
#ifdef _DEBUG #ifdef _DEBUG
long CefCppToC<CefStreamWriterCppToC, CefStreamWriter, long CefCppToC<CefStreamWriterCppToC, CefStreamWriter,
cef_stream_writer_t>::DebugObjCt = 0; cef_stream_writer_t>::DebugObjCt = 0;
#endif #endif

View File

@ -1,35 +1,35 @@
// Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights // Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that // reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file. // can be found in the LICENSE file.
// //
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
// //
// This file was generated by the CEF translator tool and should not edited // 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 // by hand. See the translator.README.txt file in the tools directory for
// more information. // more information.
// //
#ifndef _STREAMWRITER_CPPTOC_H #ifndef _STREAMWRITER_CPPTOC_H
#define _STREAMWRITER_CPPTOC_H #define _STREAMWRITER_CPPTOC_H
#ifndef BUILDING_CEF_SHARED #ifndef BUILDING_CEF_SHARED
#pragma message("Warning: "__FILE__" may be accessed DLL-side only") #pragma message("Warning: "__FILE__" may be accessed DLL-side only")
#else // BUILDING_CEF_SHARED #else // BUILDING_CEF_SHARED
#include "include/cef.h" #include "include/cef.h"
#include "include/cef_capi.h" #include "include/cef_capi.h"
#include "libcef_dll/cpptoc/cpptoc.h" #include "libcef_dll/cpptoc/cpptoc.h"
// Wrap a C++ class with a C structure. // Wrap a C++ class with a C structure.
// This class may be instantiated and accessed DLL-side only. // This class may be instantiated and accessed DLL-side only.
class CefStreamWriterCppToC class CefStreamWriterCppToC
: public CefCppToC<CefStreamWriterCppToC, CefStreamWriter, : public CefCppToC<CefStreamWriterCppToC, CefStreamWriter,
cef_stream_writer_t> cef_stream_writer_t>
{ {
public: public:
CefStreamWriterCppToC(CefStreamWriter* cls); CefStreamWriterCppToC(CefStreamWriter* cls);
virtual ~CefStreamWriterCppToC() {} virtual ~CefStreamWriterCppToC() {}
}; };
#endif // BUILDING_CEF_SHARED #endif // BUILDING_CEF_SHARED
#endif // _STREAMWRITER_CPPTOC_H #endif // _STREAMWRITER_CPPTOC_H

View File

@ -1,40 +1,40 @@
// Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights // Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that // reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file. // can be found in the LICENSE file.
// //
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
// //
// A portion of this file was generated by the CEF translator tool. When // A portion of this file was generated by the CEF translator tool. When
// making changes by hand only do so within the body of existing function // making changes by hand only do so within the body of existing function
// implementations. See the translator.README.txt file in the tools directory // implementations. See the translator.README.txt file in the tools directory
// for more information. // for more information.
// //
#include "libcef_dll/cpptoc/task_cpptoc.h" #include "libcef_dll/cpptoc/task_cpptoc.h"
// MEMBER FUNCTIONS - Body may be edited by hand. // MEMBER FUNCTIONS - Body may be edited by hand.
void CEF_CALLBACK task_execute(struct _cef_task_t* self, void CEF_CALLBACK task_execute(struct _cef_task_t* self,
cef_thread_id_t threadId) cef_thread_id_t threadId)
{ {
DCHECK(self); DCHECK(self);
if(!self) if(!self)
return; return;
CefTaskCppToC::Get(self)->Execute(threadId); CefTaskCppToC::Get(self)->Execute(threadId);
} }
// CONSTRUCTOR - Do not edit by hand. // CONSTRUCTOR - Do not edit by hand.
CefTaskCppToC::CefTaskCppToC(CefTask* cls) CefTaskCppToC::CefTaskCppToC(CefTask* cls)
: CefCppToC<CefTaskCppToC, CefTask, cef_task_t>(cls) : CefCppToC<CefTaskCppToC, CefTask, cef_task_t>(cls)
{ {
struct_.struct_.execute = task_execute; struct_.struct_.execute = task_execute;
} }
#ifdef _DEBUG #ifdef _DEBUG
long CefCppToC<CefTaskCppToC, CefTask, cef_task_t>::DebugObjCt = 0; long CefCppToC<CefTaskCppToC, CefTask, cef_task_t>::DebugObjCt = 0;
#endif #endif

View File

@ -1,34 +1,34 @@
// Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights // Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that // reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file. // can be found in the LICENSE file.
// //
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
// //
// This file was generated by the CEF translator tool and should not edited // 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 // by hand. See the translator.README.txt file in the tools directory for
// more information. // more information.
// //
#ifndef _TASK_CPPTOC_H #ifndef _TASK_CPPTOC_H
#define _TASK_CPPTOC_H #define _TASK_CPPTOC_H
#ifndef USING_CEF_SHARED #ifndef USING_CEF_SHARED
#pragma message("Warning: "__FILE__" may be accessed wrapper-side only") #pragma message("Warning: "__FILE__" may be accessed wrapper-side only")
#else // USING_CEF_SHARED #else // USING_CEF_SHARED
#include "include/cef.h" #include "include/cef.h"
#include "include/cef_capi.h" #include "include/cef_capi.h"
#include "libcef_dll/cpptoc/cpptoc.h" #include "libcef_dll/cpptoc/cpptoc.h"
// Wrap a C++ class with a C structure. // Wrap a C++ class with a C structure.
// This class may be instantiated and accessed wrapper-side only. // This class may be instantiated and accessed wrapper-side only.
class CefTaskCppToC class CefTaskCppToC
: public CefCppToC<CefTaskCppToC, CefTask, cef_task_t> : public CefCppToC<CefTaskCppToC, CefTask, cef_task_t>
{ {
public: public:
CefTaskCppToC(CefTask* cls); CefTaskCppToC(CefTask* cls);
virtual ~CefTaskCppToC() {} virtual ~CefTaskCppToC() {}
}; };
#endif // USING_CEF_SHARED #endif // USING_CEF_SHARED
#endif // _TASK_CPPTOC_H #endif // _TASK_CPPTOC_H

View File

@ -1,68 +1,68 @@
// Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights // Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that // reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file. // can be found in the LICENSE file.
// //
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
// //
// A portion of this file was generated by the CEF translator tool. When // A portion of this file was generated by the CEF translator tool. When
// making changes by hand only do so within the body of existing function // making changes by hand only do so within the body of existing function
// implementations. See the translator.README.txt file in the tools directory // implementations. See the translator.README.txt file in the tools directory
// for more information. // for more information.
// //
#include "libcef_dll/cpptoc/v8handler_cpptoc.h" #include "libcef_dll/cpptoc/v8handler_cpptoc.h"
#include "libcef_dll/ctocpp/v8value_ctocpp.h" #include "libcef_dll/ctocpp/v8value_ctocpp.h"
// MEMBER FUNCTIONS - Body may be edited by hand. // MEMBER FUNCTIONS - Body may be edited by hand.
int CEF_CALLBACK v8handler_execute(struct _cef_v8handler_t* self, int CEF_CALLBACK v8handler_execute(struct _cef_v8handler_t* self,
const wchar_t* name, struct _cef_v8value_t* object, size_t argumentCount, const wchar_t* name, struct _cef_v8value_t* object, size_t argumentCount,
struct _cef_v8value_t* const* arguments, struct _cef_v8value_t** retval, struct _cef_v8value_t* const* arguments, struct _cef_v8value_t** retval,
cef_string_t* exception) cef_string_t* exception)
{ {
DCHECK(self); DCHECK(self);
if(!self) if(!self)
return RV_CONTINUE; return RV_CONTINUE;
CefRefPtr<CefV8Value> objectPtr; CefRefPtr<CefV8Value> objectPtr;
if(object) if(object)
objectPtr = CefV8ValueCToCpp::Wrap(object); objectPtr = CefV8ValueCToCpp::Wrap(object);
std::wstring nameStr; std::wstring nameStr;
if(name) if(name)
nameStr = name; nameStr = name;
CefV8ValueList list; CefV8ValueList list;
for(size_t i = 0; i < argumentCount; ++i) { for(size_t i = 0; i < argumentCount; ++i) {
list.push_back(CefV8ValueCToCpp::Wrap(arguments[i])); list.push_back(CefV8ValueCToCpp::Wrap(arguments[i]));
} }
CefRefPtr<CefV8Value> retValPtr; CefRefPtr<CefV8Value> retValPtr;
std::wstring exceptionStr; std::wstring exceptionStr;
bool rv = CefV8HandlerCppToC::Get(self)->Execute(nameStr, objectPtr, bool rv = CefV8HandlerCppToC::Get(self)->Execute(nameStr, objectPtr,
list, retValPtr, exceptionStr); list, retValPtr, exceptionStr);
if(rv) { if(rv) {
if(!exceptionStr.empty() && exception) if(!exceptionStr.empty() && exception)
*exception = cef_string_alloc(exceptionStr.c_str()); *exception = cef_string_alloc(exceptionStr.c_str());
if(retValPtr.get() && retval) if(retValPtr.get() && retval)
*retval = CefV8ValueCToCpp::Unwrap(retValPtr); *retval = CefV8ValueCToCpp::Unwrap(retValPtr);
} }
return rv; return rv;
} }
// CONSTRUCTOR - Do not edit by hand. // CONSTRUCTOR - Do not edit by hand.
CefV8HandlerCppToC::CefV8HandlerCppToC(CefV8Handler* cls) CefV8HandlerCppToC::CefV8HandlerCppToC(CefV8Handler* cls)
: CefCppToC<CefV8HandlerCppToC, CefV8Handler, cef_v8handler_t>(cls) : CefCppToC<CefV8HandlerCppToC, CefV8Handler, cef_v8handler_t>(cls)
{ {
struct_.struct_.execute = v8handler_execute; struct_.struct_.execute = v8handler_execute;
} }
#ifdef _DEBUG #ifdef _DEBUG
long CefCppToC<CefV8HandlerCppToC, CefV8Handler, cef_v8handler_t>::DebugObjCt = long CefCppToC<CefV8HandlerCppToC, CefV8Handler, cef_v8handler_t>::DebugObjCt =
0; 0;
#endif #endif

View File

@ -1,34 +1,34 @@
// Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights // Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that // reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file. // can be found in the LICENSE file.
// //
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
// //
// This file was generated by the CEF translator tool and should not edited // 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 // by hand. See the translator.README.txt file in the tools directory for
// more information. // more information.
// //
#ifndef _V8HANDLER_CPPTOC_H #ifndef _V8HANDLER_CPPTOC_H
#define _V8HANDLER_CPPTOC_H #define _V8HANDLER_CPPTOC_H
#ifndef USING_CEF_SHARED #ifndef USING_CEF_SHARED
#pragma message("Warning: "__FILE__" may be accessed wrapper-side only") #pragma message("Warning: "__FILE__" may be accessed wrapper-side only")
#else // USING_CEF_SHARED #else // USING_CEF_SHARED
#include "include/cef.h" #include "include/cef.h"
#include "include/cef_capi.h" #include "include/cef_capi.h"
#include "libcef_dll/cpptoc/cpptoc.h" #include "libcef_dll/cpptoc/cpptoc.h"
// Wrap a C++ class with a C structure. // Wrap a C++ class with a C structure.
// This class may be instantiated and accessed wrapper-side only. // This class may be instantiated and accessed wrapper-side only.
class CefV8HandlerCppToC class CefV8HandlerCppToC
: public CefCppToC<CefV8HandlerCppToC, CefV8Handler, cef_v8handler_t> : public CefCppToC<CefV8HandlerCppToC, CefV8Handler, cef_v8handler_t>
{ {
public: public:
CefV8HandlerCppToC(CefV8Handler* cls); CefV8HandlerCppToC(CefV8Handler* cls);
virtual ~CefV8HandlerCppToC() {} virtual ~CefV8HandlerCppToC() {}
}; };
#endif // USING_CEF_SHARED #endif // USING_CEF_SHARED
#endif // _V8HANDLER_CPPTOC_H #endif // _V8HANDLER_CPPTOC_H

View File

@ -1,462 +1,462 @@
// Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights // Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that // reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file. // can be found in the LICENSE file.
// //
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
// //
// A portion of this file was generated by the CEF translator tool. When // A portion of this file was generated by the CEF translator tool. When
// making changes by hand only do so within the body of existing function // making changes by hand only do so within the body of existing function
// implementations. See the translator.README.txt file in the tools directory // implementations. See the translator.README.txt file in the tools directory
// for more information. // for more information.
// //
#include "libcef_dll/cpptoc/v8value_cpptoc.h" #include "libcef_dll/cpptoc/v8value_cpptoc.h"
#include "libcef_dll/ctocpp/base_ctocpp.h" #include "libcef_dll/ctocpp/base_ctocpp.h"
#include "libcef_dll/ctocpp/v8handler_ctocpp.h" #include "libcef_dll/ctocpp/v8handler_ctocpp.h"
// GLOBAL FUNCTIONS - Body may be edited by hand. // GLOBAL FUNCTIONS - Body may be edited by hand.
CEF_EXPORT cef_v8value_t* cef_v8value_create_undefined() CEF_EXPORT cef_v8value_t* cef_v8value_create_undefined()
{ {
CefRefPtr<CefV8Value> impl = CefV8Value::CreateUndefined(); CefRefPtr<CefV8Value> impl = CefV8Value::CreateUndefined();
if(impl.get()) if(impl.get())
return CefV8ValueCppToC::Wrap(impl); return CefV8ValueCppToC::Wrap(impl);
return NULL; return NULL;
} }
CEF_EXPORT cef_v8value_t* cef_v8value_create_null() CEF_EXPORT cef_v8value_t* cef_v8value_create_null()
{ {
CefRefPtr<CefV8Value> impl = CefV8Value::CreateNull(); CefRefPtr<CefV8Value> impl = CefV8Value::CreateNull();
if(impl.get()) if(impl.get())
return CefV8ValueCppToC::Wrap(impl); return CefV8ValueCppToC::Wrap(impl);
return NULL; return NULL;
} }
CEF_EXPORT cef_v8value_t* cef_v8value_create_bool(int value) CEF_EXPORT cef_v8value_t* cef_v8value_create_bool(int value)
{ {
CefRefPtr<CefV8Value> impl = CefV8Value::CreateBool(value?true:false); CefRefPtr<CefV8Value> impl = CefV8Value::CreateBool(value?true:false);
if(impl.get()) if(impl.get())
return CefV8ValueCppToC::Wrap(impl); return CefV8ValueCppToC::Wrap(impl);
return NULL; return NULL;
} }
CEF_EXPORT cef_v8value_t* cef_v8value_create_int(int value) CEF_EXPORT cef_v8value_t* cef_v8value_create_int(int value)
{ {
CefRefPtr<CefV8Value> impl = CefV8Value::CreateInt(value); CefRefPtr<CefV8Value> impl = CefV8Value::CreateInt(value);
if(impl.get()) if(impl.get())
return CefV8ValueCppToC::Wrap(impl); return CefV8ValueCppToC::Wrap(impl);
return NULL; return NULL;
} }
CEF_EXPORT cef_v8value_t* cef_v8value_create_double(double value) CEF_EXPORT cef_v8value_t* cef_v8value_create_double(double value)
{ {
CefRefPtr<CefV8Value> impl = CefV8Value::CreateDouble(value); CefRefPtr<CefV8Value> impl = CefV8Value::CreateDouble(value);
if(impl.get()) if(impl.get())
return CefV8ValueCppToC::Wrap(impl); return CefV8ValueCppToC::Wrap(impl);
return NULL; return NULL;
} }
CEF_EXPORT cef_v8value_t* cef_v8value_create_string(const wchar_t* value) CEF_EXPORT cef_v8value_t* cef_v8value_create_string(const wchar_t* value)
{ {
std::wstring valueStr; std::wstring valueStr;
if(value) if(value)
valueStr = value; valueStr = value;
CefRefPtr<CefV8Value> impl = CefV8Value::CreateString(valueStr); CefRefPtr<CefV8Value> impl = CefV8Value::CreateString(valueStr);
if(impl.get()) if(impl.get())
return CefV8ValueCppToC::Wrap(impl); return CefV8ValueCppToC::Wrap(impl);
return NULL; return NULL;
} }
CEF_EXPORT cef_v8value_t* cef_v8value_create_object(cef_base_t* user_data) CEF_EXPORT cef_v8value_t* cef_v8value_create_object(cef_base_t* user_data)
{ {
CefRefPtr<CefBase> basePtr; CefRefPtr<CefBase> basePtr;
if(user_data) if(user_data)
basePtr = CefBaseCToCpp::Wrap(user_data); basePtr = CefBaseCToCpp::Wrap(user_data);
CefRefPtr<CefV8Value> impl = CefV8Value::CreateObject(basePtr); CefRefPtr<CefV8Value> impl = CefV8Value::CreateObject(basePtr);
if(impl.get()) if(impl.get())
return CefV8ValueCppToC::Wrap(impl); return CefV8ValueCppToC::Wrap(impl);
return NULL; return NULL;
} }
CEF_EXPORT cef_v8value_t* cef_v8value_create_array() CEF_EXPORT cef_v8value_t* cef_v8value_create_array()
{ {
CefRefPtr<CefV8Value> impl = CefV8Value::CreateArray(); CefRefPtr<CefV8Value> impl = CefV8Value::CreateArray();
if(impl.get()) if(impl.get())
return CefV8ValueCppToC::Wrap(impl); return CefV8ValueCppToC::Wrap(impl);
return NULL; return NULL;
} }
CEF_EXPORT cef_v8value_t* cef_v8value_create_function(const wchar_t* name, CEF_EXPORT cef_v8value_t* cef_v8value_create_function(const wchar_t* name,
cef_v8handler_t* handler) cef_v8handler_t* handler)
{ {
std::wstring nameStr; std::wstring nameStr;
if(name) if(name)
nameStr = name; nameStr = name;
CefRefPtr<CefV8Handler> handlerPtr; CefRefPtr<CefV8Handler> handlerPtr;
if(handler) if(handler)
handlerPtr = CefV8HandlerCToCpp::Wrap(handler); handlerPtr = CefV8HandlerCToCpp::Wrap(handler);
CefRefPtr<CefV8Value> impl = CefV8Value::CreateFunction(nameStr, handlerPtr); CefRefPtr<CefV8Value> impl = CefV8Value::CreateFunction(nameStr, handlerPtr);
if(impl.get()) if(impl.get())
return CefV8ValueCppToC::Wrap(impl); return CefV8ValueCppToC::Wrap(impl);
return NULL; return NULL;
} }
// MEMBER FUNCTIONS - Body may be edited by hand. // MEMBER FUNCTIONS - Body may be edited by hand.
int CEF_CALLBACK v8value_is_undefined(struct _cef_v8value_t* self) int CEF_CALLBACK v8value_is_undefined(struct _cef_v8value_t* self)
{ {
DCHECK(self); DCHECK(self);
if(!self) if(!self)
return 0; return 0;
return CefV8ValueCppToC::Get(self)->IsUndefined(); return CefV8ValueCppToC::Get(self)->IsUndefined();
} }
int CEF_CALLBACK v8value_is_null(struct _cef_v8value_t* self) int CEF_CALLBACK v8value_is_null(struct _cef_v8value_t* self)
{ {
DCHECK(self); DCHECK(self);
if(!self) if(!self)
return 0; return 0;
return CefV8ValueCppToC::Get(self)->IsNull(); return CefV8ValueCppToC::Get(self)->IsNull();
} }
int CEF_CALLBACK v8value_is_bool(struct _cef_v8value_t* self) int CEF_CALLBACK v8value_is_bool(struct _cef_v8value_t* self)
{ {
DCHECK(self); DCHECK(self);
if(!self) if(!self)
return 0; return 0;
return CefV8ValueCppToC::Get(self)->IsBool(); return CefV8ValueCppToC::Get(self)->IsBool();
} }
int CEF_CALLBACK v8value_is_int(struct _cef_v8value_t* self) int CEF_CALLBACK v8value_is_int(struct _cef_v8value_t* self)
{ {
DCHECK(self); DCHECK(self);
if(!self) if(!self)
return 0; return 0;
return CefV8ValueCppToC::Get(self)->IsInt(); return CefV8ValueCppToC::Get(self)->IsInt();
} }
int CEF_CALLBACK v8value_is_double(struct _cef_v8value_t* self) int CEF_CALLBACK v8value_is_double(struct _cef_v8value_t* self)
{ {
DCHECK(self); DCHECK(self);
if(!self) if(!self)
return 0; return 0;
return CefV8ValueCppToC::Get(self)->IsDouble(); return CefV8ValueCppToC::Get(self)->IsDouble();
} }
int CEF_CALLBACK v8value_is_string(struct _cef_v8value_t* self) int CEF_CALLBACK v8value_is_string(struct _cef_v8value_t* self)
{ {
DCHECK(self); DCHECK(self);
if(!self) if(!self)
return 0; return 0;
return CefV8ValueCppToC::Get(self)->IsString(); return CefV8ValueCppToC::Get(self)->IsString();
} }
int CEF_CALLBACK v8value_is_object(struct _cef_v8value_t* self) int CEF_CALLBACK v8value_is_object(struct _cef_v8value_t* self)
{ {
DCHECK(self); DCHECK(self);
if(!self) if(!self)
return 0; return 0;
return CefV8ValueCppToC::Get(self)->IsObject(); return CefV8ValueCppToC::Get(self)->IsObject();
} }
int CEF_CALLBACK v8value_is_array(struct _cef_v8value_t* self) int CEF_CALLBACK v8value_is_array(struct _cef_v8value_t* self)
{ {
DCHECK(self); DCHECK(self);
if(!self) if(!self)
return 0; return 0;
return CefV8ValueCppToC::Get(self)->IsArray(); return CefV8ValueCppToC::Get(self)->IsArray();
} }
int CEF_CALLBACK v8value_is_function(struct _cef_v8value_t* self) int CEF_CALLBACK v8value_is_function(struct _cef_v8value_t* self)
{ {
DCHECK(self); DCHECK(self);
if(!self) if(!self)
return 0; return 0;
return CefV8ValueCppToC::Get(self)->IsFunction(); return CefV8ValueCppToC::Get(self)->IsFunction();
} }
int CEF_CALLBACK v8value_get_bool_value(struct _cef_v8value_t* self) int CEF_CALLBACK v8value_get_bool_value(struct _cef_v8value_t* self)
{ {
DCHECK(self); DCHECK(self);
if(!self) if(!self)
return 0; return 0;
return CefV8ValueCppToC::Get(self)->GetBoolValue(); return CefV8ValueCppToC::Get(self)->GetBoolValue();
} }
int CEF_CALLBACK v8value_get_int_value(struct _cef_v8value_t* self) int CEF_CALLBACK v8value_get_int_value(struct _cef_v8value_t* self)
{ {
DCHECK(self); DCHECK(self);
if(!self) if(!self)
return 0; return 0;
return CefV8ValueCppToC::Get(self)->GetIntValue(); return CefV8ValueCppToC::Get(self)->GetIntValue();
} }
double CEF_CALLBACK v8value_get_double_value(struct _cef_v8value_t* self) double CEF_CALLBACK v8value_get_double_value(struct _cef_v8value_t* self)
{ {
DCHECK(self); DCHECK(self);
if(!self) if(!self)
return 0; return 0;
return CefV8ValueCppToC::Get(self)->GetDoubleValue(); return CefV8ValueCppToC::Get(self)->GetDoubleValue();
} }
cef_string_t CEF_CALLBACK v8value_get_string_value(struct _cef_v8value_t* self) cef_string_t CEF_CALLBACK v8value_get_string_value(struct _cef_v8value_t* self)
{ {
DCHECK(self); DCHECK(self);
if(!self) if(!self)
return 0; return 0;
std::wstring valueStr = CefV8ValueCppToC::Get(self)->GetStringValue(); std::wstring valueStr = CefV8ValueCppToC::Get(self)->GetStringValue();
if(!valueStr.empty()) if(!valueStr.empty())
return cef_string_alloc(valueStr.c_str()); return cef_string_alloc(valueStr.c_str());
return NULL; return NULL;
} }
int CEF_CALLBACK v8value_has_value_bykey(struct _cef_v8value_t* self, int CEF_CALLBACK v8value_has_value_bykey(struct _cef_v8value_t* self,
const wchar_t* key) const wchar_t* key)
{ {
DCHECK(self); DCHECK(self);
if(!self) if(!self)
return 0; return 0;
std::wstring keyStr; std::wstring keyStr;
if(key) if(key)
keyStr = key; keyStr = key;
return CefV8ValueCppToC::Get(self)->HasValue(keyStr); return CefV8ValueCppToC::Get(self)->HasValue(keyStr);
} }
int CEF_CALLBACK v8value_has_value_byindex(struct _cef_v8value_t* self, int CEF_CALLBACK v8value_has_value_byindex(struct _cef_v8value_t* self,
int index) int index)
{ {
DCHECK(self); DCHECK(self);
if(!self) if(!self)
return 0; return 0;
return CefV8ValueCppToC::Get(self)->HasValue(index); return CefV8ValueCppToC::Get(self)->HasValue(index);
} }
int CEF_CALLBACK v8value_delete_value_bykey(struct _cef_v8value_t* self, int CEF_CALLBACK v8value_delete_value_bykey(struct _cef_v8value_t* self,
const wchar_t* key) const wchar_t* key)
{ {
DCHECK(self); DCHECK(self);
if(!self) if(!self)
return 0; return 0;
std::wstring keyStr; std::wstring keyStr;
if(key) if(key)
keyStr = key; keyStr = key;
return CefV8ValueCppToC::Get(self)->DeleteValue(keyStr); return CefV8ValueCppToC::Get(self)->DeleteValue(keyStr);
} }
int CEF_CALLBACK v8value_delete_value_byindex(struct _cef_v8value_t* self, int CEF_CALLBACK v8value_delete_value_byindex(struct _cef_v8value_t* self,
int index) int index)
{ {
DCHECK(self); DCHECK(self);
if(!self) if(!self)
return 0; return 0;
return CefV8ValueCppToC::Get(self)->DeleteValue(index); return CefV8ValueCppToC::Get(self)->DeleteValue(index);
} }
struct _cef_v8value_t* CEF_CALLBACK v8value_get_value_bykey( struct _cef_v8value_t* CEF_CALLBACK v8value_get_value_bykey(
struct _cef_v8value_t* self, const wchar_t* key) struct _cef_v8value_t* self, const wchar_t* key)
{ {
DCHECK(self); DCHECK(self);
if(!self) if(!self)
return 0; return 0;
std::wstring keyStr; std::wstring keyStr;
if(key) if(key)
keyStr = key; keyStr = key;
CefRefPtr<CefV8Value> valuePtr = CefRefPtr<CefV8Value> valuePtr =
CefV8ValueCppToC::Get(self)->GetValue(keyStr); CefV8ValueCppToC::Get(self)->GetValue(keyStr);
return CefV8ValueCppToC::Wrap(valuePtr); return CefV8ValueCppToC::Wrap(valuePtr);
} }
struct _cef_v8value_t* CEF_CALLBACK v8value_get_value_byindex( struct _cef_v8value_t* CEF_CALLBACK v8value_get_value_byindex(
struct _cef_v8value_t* self, int index) struct _cef_v8value_t* self, int index)
{ {
DCHECK(self); DCHECK(self);
if(!self) if(!self)
return 0; return 0;
CefRefPtr<CefV8Value> valuePtr = CefRefPtr<CefV8Value> valuePtr =
CefV8ValueCppToC::Get(self)->GetValue(index); CefV8ValueCppToC::Get(self)->GetValue(index);
return CefV8ValueCppToC::Wrap(valuePtr); return CefV8ValueCppToC::Wrap(valuePtr);
} }
int CEF_CALLBACK v8value_set_value_bykey(struct _cef_v8value_t* self, int CEF_CALLBACK v8value_set_value_bykey(struct _cef_v8value_t* self,
const wchar_t* key, struct _cef_v8value_t* value) const wchar_t* key, struct _cef_v8value_t* value)
{ {
DCHECK(self); DCHECK(self);
if(!self) if(!self)
return 0; return 0;
std::wstring keyStr; std::wstring keyStr;
if(key) if(key)
keyStr = key; keyStr = key;
CefRefPtr<CefV8Value> valuePtr = CefV8ValueCppToC::Unwrap(value); CefRefPtr<CefV8Value> valuePtr = CefV8ValueCppToC::Unwrap(value);
return CefV8ValueCppToC::Get(self)->SetValue(keyStr, valuePtr); return CefV8ValueCppToC::Get(self)->SetValue(keyStr, valuePtr);
} }
int CEF_CALLBACK v8value_set_value_byindex(struct _cef_v8value_t* self, int CEF_CALLBACK v8value_set_value_byindex(struct _cef_v8value_t* self,
int index, struct _cef_v8value_t* value) int index, struct _cef_v8value_t* value)
{ {
DCHECK(self); DCHECK(self);
if(!self) if(!self)
return 0; return 0;
CefRefPtr<CefV8Value> valuePtr = CefV8ValueCppToC::Unwrap(value); CefRefPtr<CefV8Value> valuePtr = CefV8ValueCppToC::Unwrap(value);
return CefV8ValueCppToC::Get(self)->SetValue(index, valuePtr); return CefV8ValueCppToC::Get(self)->SetValue(index, valuePtr);
} }
int CEF_CALLBACK v8value_get_keys(struct _cef_v8value_t* self, int CEF_CALLBACK v8value_get_keys(struct _cef_v8value_t* self,
cef_string_list_t keys) cef_string_list_t keys)
{ {
DCHECK(self); DCHECK(self);
if(!self) if(!self)
return 0; return 0;
std::vector<std::wstring> keysList; std::vector<std::wstring> keysList;
CefV8ValueCppToC::Get(self)->GetKeys(keysList); CefV8ValueCppToC::Get(self)->GetKeys(keysList);
size_t size = keysList.size(); size_t size = keysList.size();
for(size_t i = 0; i < size; ++i) for(size_t i = 0; i < size; ++i)
cef_string_list_append(keys, keysList[i].c_str()); cef_string_list_append(keys, keysList[i].c_str());
return size; return size;
} }
cef_base_t* CEF_CALLBACK v8value_get_user_data(struct _cef_v8value_t* self) cef_base_t* CEF_CALLBACK v8value_get_user_data(struct _cef_v8value_t* self)
{ {
DCHECK(self); DCHECK(self);
if(!self) if(!self)
return 0; return 0;
CefRefPtr<CefBase> base = CefV8ValueCppToC::Get(self)->GetUserData(); CefRefPtr<CefBase> base = CefV8ValueCppToC::Get(self)->GetUserData();
if(base.get()) if(base.get())
return CefBaseCToCpp::Unwrap(base); return CefBaseCToCpp::Unwrap(base);
return NULL; return NULL;
} }
int CEF_CALLBACK v8value_get_array_length(struct _cef_v8value_t* self) int CEF_CALLBACK v8value_get_array_length(struct _cef_v8value_t* self)
{ {
DCHECK(self); DCHECK(self);
if(!self) if(!self)
return 0; return 0;
return CefV8ValueCppToC::Get(self)->GetArrayLength(); return CefV8ValueCppToC::Get(self)->GetArrayLength();
} }
cef_string_t CEF_CALLBACK v8value_get_function_name(struct _cef_v8value_t* self) cef_string_t CEF_CALLBACK v8value_get_function_name(struct _cef_v8value_t* self)
{ {
DCHECK(self); DCHECK(self);
if(!self) if(!self)
return 0; return 0;
std::wstring functionNameStr = std::wstring functionNameStr =
CefV8ValueCppToC::Get(self)->GetFunctionName(); CefV8ValueCppToC::Get(self)->GetFunctionName();
if(!functionNameStr.empty()) if(!functionNameStr.empty())
return cef_string_alloc(functionNameStr.c_str()); return cef_string_alloc(functionNameStr.c_str());
return NULL; return NULL;
} }
cef_v8handler_t* CEF_CALLBACK v8value_get_function_handler( cef_v8handler_t* CEF_CALLBACK v8value_get_function_handler(
struct _cef_v8value_t* self) struct _cef_v8value_t* self)
{ {
DCHECK(self); DCHECK(self);
if(!self) if(!self)
return 0; return 0;
CefRefPtr<CefV8Handler> handlerPtr = CefRefPtr<CefV8Handler> handlerPtr =
CefV8ValueCppToC::Get(self)->GetFunctionHandler(); CefV8ValueCppToC::Get(self)->GetFunctionHandler();
if(handlerPtr.get()) if(handlerPtr.get())
return CefV8HandlerCToCpp::Unwrap(handlerPtr); return CefV8HandlerCToCpp::Unwrap(handlerPtr);
return NULL; return NULL;
} }
int CEF_CALLBACK v8value_execute_function(struct _cef_v8value_t* self, int CEF_CALLBACK v8value_execute_function(struct _cef_v8value_t* self,
struct _cef_v8value_t* object, size_t argumentCount, struct _cef_v8value_t* object, size_t argumentCount,
struct _cef_v8value_t* const* arguments, struct _cef_v8value_t** retval, struct _cef_v8value_t* const* arguments, struct _cef_v8value_t** retval,
cef_string_t* exception) cef_string_t* exception)
{ {
DCHECK(self); DCHECK(self);
DCHECK(object); DCHECK(object);
if(!self || !object) if(!self || !object)
return 0; return 0;
CefRefPtr<CefV8Value> objectPtr = CefV8ValueCppToC::Unwrap(object); CefRefPtr<CefV8Value> objectPtr = CefV8ValueCppToC::Unwrap(object);
CefV8ValueList argsList; CefV8ValueList argsList;
for(size_t i = 0; i < argumentCount; i++) { for(size_t i = 0; i < argumentCount; i++) {
argsList.push_back(CefV8ValueCppToC::Unwrap(arguments[i])); argsList.push_back(CefV8ValueCppToC::Unwrap(arguments[i]));
} }
CefRefPtr<CefV8Value> retvalPtr; CefRefPtr<CefV8Value> retvalPtr;
std::wstring exceptionStr; std::wstring exceptionStr;
bool rv = CefV8ValueCppToC::Get(self)->ExecuteFunction(objectPtr, bool rv = CefV8ValueCppToC::Get(self)->ExecuteFunction(objectPtr,
argsList, retvalPtr, exceptionStr); argsList, retvalPtr, exceptionStr);
if(retvalPtr.get() && retval) if(retvalPtr.get() && retval)
*retval = CefV8ValueCppToC::Wrap(retvalPtr); *retval = CefV8ValueCppToC::Wrap(retvalPtr);
if(!exceptionStr.empty() && exception) if(!exceptionStr.empty() && exception)
*exception = cef_string_alloc(exceptionStr.c_str()); *exception = cef_string_alloc(exceptionStr.c_str());
return rv; return rv;
} }
// CONSTRUCTOR - Do not edit by hand. // CONSTRUCTOR - Do not edit by hand.
CefV8ValueCppToC::CefV8ValueCppToC(CefV8Value* cls) CefV8ValueCppToC::CefV8ValueCppToC(CefV8Value* cls)
: CefCppToC<CefV8ValueCppToC, CefV8Value, cef_v8value_t>(cls) : CefCppToC<CefV8ValueCppToC, CefV8Value, cef_v8value_t>(cls)
{ {
struct_.struct_.is_undefined = v8value_is_undefined; struct_.struct_.is_undefined = v8value_is_undefined;
struct_.struct_.is_null = v8value_is_null; struct_.struct_.is_null = v8value_is_null;
struct_.struct_.is_bool = v8value_is_bool; struct_.struct_.is_bool = v8value_is_bool;
struct_.struct_.is_int = v8value_is_int; struct_.struct_.is_int = v8value_is_int;
struct_.struct_.is_double = v8value_is_double; struct_.struct_.is_double = v8value_is_double;
struct_.struct_.is_string = v8value_is_string; struct_.struct_.is_string = v8value_is_string;
struct_.struct_.is_object = v8value_is_object; struct_.struct_.is_object = v8value_is_object;
struct_.struct_.is_array = v8value_is_array; struct_.struct_.is_array = v8value_is_array;
struct_.struct_.is_function = v8value_is_function; struct_.struct_.is_function = v8value_is_function;
struct_.struct_.get_bool_value = v8value_get_bool_value; struct_.struct_.get_bool_value = v8value_get_bool_value;
struct_.struct_.get_int_value = v8value_get_int_value; struct_.struct_.get_int_value = v8value_get_int_value;
struct_.struct_.get_double_value = v8value_get_double_value; struct_.struct_.get_double_value = v8value_get_double_value;
struct_.struct_.get_string_value = v8value_get_string_value; struct_.struct_.get_string_value = v8value_get_string_value;
struct_.struct_.has_value_bykey = v8value_has_value_bykey; struct_.struct_.has_value_bykey = v8value_has_value_bykey;
struct_.struct_.has_value_byindex = v8value_has_value_byindex; struct_.struct_.has_value_byindex = v8value_has_value_byindex;
struct_.struct_.delete_value_bykey = v8value_delete_value_bykey; struct_.struct_.delete_value_bykey = v8value_delete_value_bykey;
struct_.struct_.delete_value_byindex = v8value_delete_value_byindex; struct_.struct_.delete_value_byindex = v8value_delete_value_byindex;
struct_.struct_.get_value_bykey = v8value_get_value_bykey; struct_.struct_.get_value_bykey = v8value_get_value_bykey;
struct_.struct_.get_value_byindex = v8value_get_value_byindex; struct_.struct_.get_value_byindex = v8value_get_value_byindex;
struct_.struct_.set_value_bykey = v8value_set_value_bykey; struct_.struct_.set_value_bykey = v8value_set_value_bykey;
struct_.struct_.set_value_byindex = v8value_set_value_byindex; struct_.struct_.set_value_byindex = v8value_set_value_byindex;
struct_.struct_.get_keys = v8value_get_keys; struct_.struct_.get_keys = v8value_get_keys;
struct_.struct_.get_user_data = v8value_get_user_data; struct_.struct_.get_user_data = v8value_get_user_data;
struct_.struct_.get_array_length = v8value_get_array_length; struct_.struct_.get_array_length = v8value_get_array_length;
struct_.struct_.get_function_name = v8value_get_function_name; struct_.struct_.get_function_name = v8value_get_function_name;
struct_.struct_.get_function_handler = v8value_get_function_handler; struct_.struct_.get_function_handler = v8value_get_function_handler;
struct_.struct_.execute_function = v8value_execute_function; struct_.struct_.execute_function = v8value_execute_function;
} }
#ifdef _DEBUG #ifdef _DEBUG
long CefCppToC<CefV8ValueCppToC, CefV8Value, cef_v8value_t>::DebugObjCt = 0; long CefCppToC<CefV8ValueCppToC, CefV8Value, cef_v8value_t>::DebugObjCt = 0;
#endif #endif

View File

@ -1,34 +1,34 @@
// Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights // Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that // reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file. // can be found in the LICENSE file.
// //
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
// //
// This file was generated by the CEF translator tool and should not edited // 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 // by hand. See the translator.README.txt file in the tools directory for
// more information. // more information.
// //
#ifndef _V8VALUE_CPPTOC_H #ifndef _V8VALUE_CPPTOC_H
#define _V8VALUE_CPPTOC_H #define _V8VALUE_CPPTOC_H
#ifndef BUILDING_CEF_SHARED #ifndef BUILDING_CEF_SHARED
#pragma message("Warning: "__FILE__" may be accessed DLL-side only") #pragma message("Warning: "__FILE__" may be accessed DLL-side only")
#else // BUILDING_CEF_SHARED #else // BUILDING_CEF_SHARED
#include "include/cef.h" #include "include/cef.h"
#include "include/cef_capi.h" #include "include/cef_capi.h"
#include "libcef_dll/cpptoc/cpptoc.h" #include "libcef_dll/cpptoc/cpptoc.h"
// Wrap a C++ class with a C structure. // Wrap a C++ class with a C structure.
// This class may be instantiated and accessed DLL-side only. // This class may be instantiated and accessed DLL-side only.
class CefV8ValueCppToC class CefV8ValueCppToC
: public CefCppToC<CefV8ValueCppToC, CefV8Value, cef_v8value_t> : public CefCppToC<CefV8ValueCppToC, CefV8Value, cef_v8value_t>
{ {
public: public:
CefV8ValueCppToC(CefV8Value* cls); CefV8ValueCppToC(CefV8Value* cls);
virtual ~CefV8ValueCppToC() {} virtual ~CefV8ValueCppToC() {}
}; };
#endif // BUILDING_CEF_SHARED #endif // BUILDING_CEF_SHARED
#endif // _V8VALUE_CPPTOC_H #endif // _V8VALUE_CPPTOC_H

Some files were not shown because too many files have changed in this diff Show More