diff --git a/cef_paths.gypi b/cef_paths.gypi index 5ef2811ea..cc24cca92 100644 --- a/cef_paths.gypi +++ b/cef_paths.gypi @@ -10,6 +10,7 @@ 'include/cef_nplugin.h', 'include/cef_nplugin_capi.h', 'include/cef_runnable.h', + 'include/cef_version.h', 'include/cef_wrapper.h', 'include/internal/cef_build.h', 'include/internal/cef_export.h', diff --git a/include/cef_capi.h b/include/cef_capi.h index eb4e446a4..c7ce5bf66 100644 --- a/include/cef_capi.h +++ b/include/cef_capi.h @@ -157,7 +157,9 @@ CEF_EXPORT int cef_register_extension(const cef_string_t* extension_name, // 2.1 of RFC 1123. These URLs will be canonicalized to "scheme://host/path" in // the simplest case and "scheme://username:password@host:port/path" in the most // explicit case. For example, "scheme:host/path" and "scheme:///host/path" will -// both be canonicalized to "scheme://host/path". +// both be canonicalized to "scheme://host/path". The origin of a standard +// scheme URL is the combination of scheme, host and port (i.e., +// "scheme://host:port" in the most explicit case). // // For non-standard scheme URLs only the "scheme:" component is parsed and // canonicalized. The remainder of the URL will be passed to the handler as-is. @@ -165,8 +167,14 @@ CEF_EXPORT int cef_register_extension(const cef_string_t* extension_name, // scheme URLs cannot be used as a target for form submission. // // If |is_local| is true (1) the scheme will be treated as local (i.e., with the -// same security rules as those applied to "file" URLs). This means that normal -// pages cannot link to or access URLs of this scheme. +// same security rules as those applied to "file" URLs). Normal pages cannot +// link to or access local URLs. Also, by default, local URLs can only perform +// XMLHttpRequest calls to the same URL (origin + path) that originated the +// request. To allow XMLHttpRequest calls from a local URL to other URLs with +// the same origin set the CefSettings.file_access_from_file_urls_allowed value +// to true (1). To allow XMLHttpRequest calls from a local URL to all origins +// set the CefSettings.universal_access_from_file_urls_allowed value to true +// (1). // // If |is_display_isolated| is true (1) the scheme will be treated as display- // isolated. This means that pages cannot display these URLs unless they are @@ -206,7 +214,7 @@ CEF_EXPORT int cef_clear_scheme_handler_factories(); // Add an entry to the cross-origin access whitelist. // // The same-origin policy restricts how scripts hosted from different origins -// (scheme + domain) can communicate. By default, scripts can only access +// (scheme + domain + port) can communicate. By default, scripts can only access // resources with the same origin. Scripts hosted on the HTTP and HTTPS schemes // (but no other schemes) can use the "Access-Control-Allow-Origin" header to // allow cross-origin requests. For example, https://source.example.com can make @@ -225,9 +233,14 @@ CEF_EXPORT int cef_clear_scheme_handler_factories(); // |source_origin| URL (like http://www.example.com) will be allowed access to // all resources hosted on the specified |target_protocol| and |target_domain|. // If |allow_target_subdomains| is true (1) access will also be allowed to all -// subdomains of the target domain. This function may be called on any thread. -// Returns false (0) if |source_origin| is invalid or the whitelist cannot be -// accessed. +// subdomains of the target domain. +// +// This function cannot be used to bypass the restrictions on local or display +// isolated schemes. See the comments on CefRegisterCustomScheme for more +// information. +// +// This function may be called on any thread. Returns false (0) if +// |source_origin| is invalid or the whitelist cannot be accessed. /// CEF_EXPORT int cef_add_cross_origin_whitelist_entry( const cef_string_t* source_origin, const cef_string_t* target_protocol, diff --git a/libcef/cef_process_ui_thread.cc b/libcef/cef_process_ui_thread.cc index afbb835f9..b4c2ebc3f 100644 --- a/libcef/cef_process_ui_thread.cc +++ b/libcef/cef_process_ui_thread.cc @@ -7,7 +7,7 @@ #include "browser_webkit_glue.h" #include "browser_webkit_init.h" #include "cef_context.h" -#include "../version.h" +#include "include/cef_version.h" #include "base/bind.h" #include "base/command_line.h" diff --git a/libcef_dll/ctocpp/command_line_ctocpp.cc b/libcef_dll/ctocpp/command_line_ctocpp.cc index 9d9262bc6..86096131b 100644 --- a/libcef_dll/ctocpp/command_line_ctocpp.cc +++ b/libcef_dll/ctocpp/command_line_ctocpp.cc @@ -10,6 +10,7 @@ // tools directory for more information. // +#include "include/cef_version.h" #include "libcef_dll/ctocpp/command_line_ctocpp.h" #include "libcef_dll/transfer_util.h" @@ -18,6 +19,13 @@ CefRefPtr CefCommandLine::CreateCommandLine() { + int build_revision = cef_build_revision(); + if (build_revision != CEF_REVISION) { + // The libcef build revision does not match the CEF API revision. + DCHECK(FALSE); + return NULL; + } + cef_command_line_t* impl = cef_command_line_create(); if(impl) return CefCommandLineCToCpp::Wrap(impl); diff --git a/libcef_dll/libcef_dll.cc b/libcef_dll/libcef_dll.cc index 4ff33b06a..7ea717e54 100644 --- a/libcef_dll/libcef_dll.cc +++ b/libcef_dll/libcef_dll.cc @@ -4,6 +4,7 @@ #include "include/cef.h" #include "include/cef_capi.h" +#include "include/cef_version.h" #include "include/cef_nplugin.h" #include "include/cef_nplugin_capi.h" #include "cef_logging.h" @@ -38,6 +39,11 @@ #include "base/string_split.h" +CEF_EXPORT int cef_build_revision() +{ + return CEF_REVISION; +} + CEF_EXPORT int cef_initialize(const struct _cef_settings_t* settings) { CefSettings settingsObj; diff --git a/libcef_dll/libcef_dll.rc b/libcef_dll/libcef_dll.rc index 4c7c39e27..4166aef79 100644 --- a/libcef_dll/libcef_dll.rc +++ b/libcef_dll/libcef_dll.rc @@ -9,8 +9,8 @@ // #define APSTUDIO_HIDDEN_SYMBOLS #include "windows.h" +#include "include/cef_version.h" #undef APSTUDIO_HIDDEN_SYMBOLS -#include "../version.h" ///////////////////////////////////////////////////////////////////////////// #undef APSTUDIO_READONLY_SYMBOLS @@ -39,8 +39,8 @@ END BEGIN "#define APSTUDIO_HIDDEN_SYMBOLS\r\n" "#include ""windows.h""\r\n" + "#include ""include/version.h""\r\n" "#undef APSTUDIO_HIDDEN_SYMBOLS\r\n" - "#include ""version.h""\r\n" "\0" END diff --git a/libcef_dll/wrapper/libcef_dll_wrapper.cc b/libcef_dll/wrapper/libcef_dll_wrapper.cc index 05db9ad6e..5bfb8575e 100644 --- a/libcef_dll/wrapper/libcef_dll_wrapper.cc +++ b/libcef_dll/wrapper/libcef_dll_wrapper.cc @@ -6,6 +6,7 @@ #include "include/cef_capi.h" #include "include/cef_nplugin.h" #include "include/cef_nplugin_capi.h" +#include "include/cef_version.h" #include "libcef_dll/cpptoc/content_filter_cpptoc.h" #include "libcef_dll/cpptoc/cookie_visitor_cpptoc.h" #include "libcef_dll/cpptoc/domevent_listener_cpptoc.h" @@ -38,6 +39,13 @@ bool CefInitialize(const CefSettings& settings) { + int build_revision = cef_build_revision(); + if (build_revision != CEF_REVISION) { + // The libcef build revision does not match the CEF API revision. + DCHECK(FALSE); + return false; + } + return cef_initialize(&settings)?true:false; } diff --git a/tools/cef_parser.py b/tools/cef_parser.py index df8a79361..afbb356c5 100644 --- a/tools/cef_parser.py +++ b/tools/cef_parser.py @@ -265,6 +265,9 @@ def format_translation_includes(body): """ result = '' + if body.find('cef_build_revision()') > 0: + result += '#include "include/cef_version.h"\n' + # identify what CppToC classes are being used p = re.compile('([A-Za-z0-9_]{1,})CppToC') list = sorted(set(p.findall(body))) diff --git a/tools/gclient_hook.py b/tools/gclient_hook.py index 15fd47926..f79c67645 100644 --- a/tools/gclient_hook.py +++ b/tools/gclient_hook.py @@ -15,7 +15,7 @@ RunAction(cef_dir, gyper) print "\nGenerating CEF version header file..." gyper = [ 'python', 'tools/make_version_header.py', - '--header', 'version.h', + '--header', 'include/cef_version.h', '--version', '../chrome/VERSION' ] RunAction(cef_dir, gyper) diff --git a/tools/make_version_header.bat b/tools/make_version_header.bat index 5e4944c2b..03337156f 100644 --- a/tools/make_version_header.bat +++ b/tools/make_version_header.bat @@ -1,2 +1,2 @@ @echo off -..\third_party\python_26\python.exe tools\make_version_header.py --header version.h --version ../chrome/VERSION +..\third_party\python_26\python.exe tools\make_version_header.py --header include\cef_version.h --version ../chrome/VERSION diff --git a/tools/make_version_header.py b/tools/make_version_header.py index bb3767cc2..f9aa10770 100644 --- a/tools/make_version_header.py +++ b/tools/make_version_header.py @@ -54,22 +54,65 @@ def write_svn_header(header, version): else: oldcontents = '' - newcontents = '// This file is generated by the make_version_header.py tool.\n'+\ - '#ifndef _VERSION_H\n'+\ - '#define _VERSION_H\n'+\ - '\n'+\ + year = get_year() + + newcontents = '// Copyright (c) '+year+' Marshall A. Greenblatt. All rights reserved.\n'+\ + '//\n'+\ + '// Redistribution and use in source and binary forms, with or without\n'+\ + '// modification, are permitted provided that the following conditions are\n'+\ + '// met:\n'+\ + '//\n'+\ + '// * Redistributions of source code must retain the above copyright\n'+\ + '// notice, this list of conditions and the following disclaimer.\n'+\ + '// * Redistributions in binary form must reproduce the above\n'+\ + '// copyright notice, this list of conditions and the following disclaimer\n'+\ + '// in the documentation and/or other materials provided with the\n'+\ + '// distribution.\n'+\ + '// * Neither the name of Google Inc. nor the name Chromium Embedded\n'+\ + '// Framework nor the names of its contributors may be used to endorse\n'+\ + '// or promote products derived from this software without specific prior\n'+\ + '// written permission.\n'+\ + '//\n'+\ + '// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n'+\ + '// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n'+\ + '// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n'+\ + '// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n'+\ + '// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n'+\ + '// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n'+\ + '// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n'+\ + '// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n'+\ + '// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n'+\ + '// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n'+\ + '// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n'+\ + '//\n'+\ + '// ---------------------------------------------------------------------------\n'+\ + '//\n'+\ + '// This file is generated by the make_version_header.py tool.\n'+\ + '//\n\n'+\ + '#ifndef _CEF_VERSION_H\n'+\ + '#define _CEF_VERSION_H\n\n'+\ '#define CEF_REVISION ' + get_revision() + '\n'+\ - '#define COPYRIGHT_YEAR ' + get_year() + '\n'+\ - '\n'+\ + '#define COPYRIGHT_YEAR ' + year + '\n\n'+\ '#define CHROME_VERSION_MAJOR ' + chrome['MAJOR'] + '\n'+\ '#define CHROME_VERSION_MINOR ' + chrome['MINOR'] + '\n'+\ '#define CHROME_VERSION_BUILD ' + chrome['BUILD'] + '\n'+\ - '#define CHROME_VERSION_PATCH ' + chrome['PATCH'] + '\n'+\ - '\n'+\ + '#define CHROME_VERSION_PATCH ' + chrome['PATCH'] + '\n\n'+\ '#define DO_MAKE_STRING(p) #p\n'+\ - '#define MAKE_STRING(p) DO_MAKE_STRING(p)\n'+\ - '\n'+\ - '#endif\n' + '#define MAKE_STRING(p) DO_MAKE_STRING(p)\n\n'+\ + '#ifndef APSTUDIO_HIDDEN_SYMBOLS\n\n'\ + '#ifdef __cplusplus\n'+\ + 'extern "C" {\n'+\ + '#endif\n\n'+\ + '#include "internal/cef_export.h"\n\n'+\ + '///\n'+\ + '// Returns the CEF build revision of the libcef library.\n'+\ + '///\n'+\ + 'CEF_EXPORT int cef_build_revision();\n\n'+\ + '#ifdef __cplusplus\n'+\ + '}\n'+\ + '#endif\n\n'+\ + '#endif // APSTUDIO_HIDDEN_SYMBOLS\n\n'+\ + '#endif // _CEF_VERSION_H\n' if newcontents != oldcontents: write_file(header, newcontents) return True