Index: build.sh =================================================================== --- build.sh (revision 0) +++ build.sh (working copy) @@ -0,0 +1,4 @@ +#!/bin/bash + + /Developer/usr/bin/xcodebuild -project cef.xcodeproj -configuration Release + Index: buildbot_make.bat =================================================================== --- buildbot_make.bat (revision 0) +++ buildbot_make.bat (working copy) @@ -0,0 +1,14 @@ +@rem Add VS 2010 to path +call "%VS100COMNTOOLS%..\..\vc\bin\vcvars32.bat" + +@rem Avoid conflicts with previously installed versions of Python +set pythonhome= + +@rem Build everything +if "%2" == "/debug" ( + devenv cef.sln %1 "debug|win32" /project libcef + devenv cef.sln %1 "debug|win32" /project libcef_dll_wrapper +) else ( + devenv cef.sln %1 "release|win32" /project libcef + devenv cef.sln %1 "release|win32" /project libcef_dll_wrapper +) Index: cef.gyp =================================================================== --- cef.gyp (revision 465) +++ cef.gyp (working copy) @@ -522,8 +522,12 @@ }, }], [ 'OS=="linux" or OS=="freebsd" or OS=="openbsd"', { - 'dependencies':[ - '<(DEPTH)/base/allocator/allocator.gyp:allocator', + 'conditions': [ + ['linux_use_tcmalloc==1', { + 'dependencies':[ + '<(DEPTH)/base/allocator/allocator.gyp:allocator', + ], + }], ], 'direct_dependent_settings': { 'cflags': [ @@ -545,6 +549,11 @@ 'target_name': 'libcef_dll_wrapper', 'type': 'static_library', 'msvs_guid': 'A9D6DC71-C0DC-4549-AEA0-3B15B44E86A9', + 'msvs_settings': { + 'VCCLCompilerTool': { + 'DebugInformationFormat': '1', + }, + }, 'dependencies': [ '<(DEPTH)/third_party/npapi/npapi.gyp:npapi', 'libcef', @@ -605,6 +614,7 @@ 'target_name': 'libcef_static', 'type': 'static_library', 'msvs_guid': 'FA39524D-3067-4141-888D-28A86C66F2B9', + 'msvs_disabled_warnings': [ 4355, 4800 ], 'defines': [ 'BUILDING_CEF_SHARED', ], @@ -652,6 +662,13 @@ '<(DEPTH)/webkit/support/webkit_support.gyp:webkit_strings', '<(DEPTH)/webkit/support/webkit_support.gyp:webkit_user_agent', ], + 'conditions': [ + ['OS=="win"', { + 'dependencies': [ + '../breakpad/breakpad.gyp:breakpad_handler', + ] + }, ] + ], 'sources': [ '<@(includes_common)', 'libcef/browser_appcache_system.cc', @@ -699,6 +716,7 @@ 'libcef/browser_webview_delegate.cc', 'libcef/browser_webview_delegate.h', 'libcef/browser_zoom_map.cc', + 'libcef/browser_zoom_map.cc', 'libcef/browser_zoom_map.h', 'libcef/cef_context.cc', 'libcef/cef_context.h', Index: cef_create_projects.bat =================================================================== --- cef_create_projects.bat (revision 465) +++ cef_create_projects.bat (working copy) @@ -1,2 +1,20 @@ +@rem Disable frame pointer omission. This allows us to get xperf call stacks. +set cl=/Oy- + @echo off +rem p4 edit ../.../*.vcproj +rem p4 edit ../.../*.sln +p4 edit ../.../*.gyp +p4 edit ../.../*.gypi + +set GYP_MSVS_VERSION=2010 +if "%1" == "/2005" ( +set GYP_MSVS_VERSION=2005 +) +set DXSDK_DIR=..\third_party\directxsdk\files\lib + +set PATH=%PATH%;..\third_party\python_26\;..\..\..\depot_tools\ ..\third_party\python_26\python.exe tools\gclient_hook.py + +p4 revert -a ../.../*.gyp +p4 revert -a ../.../*.gypi Index: cef_create_projects.sh =================================================================== --- cef_create_projects.sh (revision 465) +++ cef_create_projects.sh (working copy) @@ -1,2 +1,25 @@ #!/bin/sh -python tools/gclient_hook.py + +p4 edit ../.../*.gyp +p4 edit ../.../*.gypi + +export PATH="../../../depot_tools:$PATH" + +OS=`uname` +case $OS in +"Darwin") + export GYP_DEFINES='clang=1 mac_sdk=10.6' + ;; +"Linux") + export GYP_DEFINES='clang=0 target_arch=ia32 linux_use_tcmalloc=0 use_gconf=0 use_gio=0' + ;; +*) + echo "don't know what os we're building for, fix the script." + exit -1 + ;; +esac + +echo running gclient_hook with \$GYP_DEFINES=$GYP_DEFINES + +python tools/gclient_hook.py + Index: cef_paths.gypi =================================================================== --- cef_paths.gypi (revision 465) +++ cef_paths.gypi (working copy) @@ -162,6 +162,8 @@ 'libcef_dll/cpptoc/scheme_handler_callback_cpptoc.h', 'libcef_dll/ctocpp/scheme_handler_factory_ctocpp.cc', 'libcef_dll/ctocpp/scheme_handler_factory_ctocpp.h', + 'libcef_dll/cpptoc/security_details_cpptoc.cc', + 'libcef_dll/cpptoc/security_details_cpptoc.h', 'libcef_dll/ctocpp/storage_visitor_ctocpp.cc', 'libcef_dll/ctocpp/storage_visitor_ctocpp.h', 'libcef_dll/cpptoc/stream_reader_cpptoc.cc', @@ -266,6 +268,8 @@ 'libcef_dll/ctocpp/scheme_handler_callback_ctocpp.h', 'libcef_dll/cpptoc/scheme_handler_factory_cpptoc.cc', 'libcef_dll/cpptoc/scheme_handler_factory_cpptoc.h', + 'libcef_dll/ctocpp/security_details_ctocpp.cc', + 'libcef_dll/ctocpp/security_details_ctocpp.h', 'libcef_dll/cpptoc/storage_visitor_cpptoc.cc', 'libcef_dll/cpptoc/storage_visitor_cpptoc.h', 'libcef_dll/ctocpp/stream_reader_ctocpp.cc', Index: include/capi/cef_app_capi.h =================================================================== --- include/capi/cef_app_capi.h (revision 465) +++ include/capi/cef_app_capi.h (working copy) @@ -52,7 +52,7 @@ // indicates that it failed. /// CEF_EXPORT int cef_initialize(const struct _cef_settings_t* settings, - struct _cef_app_t* application); + struct _cef_app_t* application, const cef_string_t* pchResourceDLL); /// // This function should be called on the main application thread to shut down Index: include/capi/cef_browser_capi.h =================================================================== --- include/capi/cef_browser_capi.h (revision 465) +++ include/capi/cef_browser_capi.h (working copy) @@ -239,7 +239,7 @@ /// // Invalidate the |dirtyRect| region of the view. This function is only used // when window rendering is disabled and will result in a call to - // HandlePaint(). + // Handlepaint(). /// void (CEF_CALLBACK *invalidate)(struct _cef_browser_t* self, const cef_rect_t* dirtyRect); @@ -294,6 +294,61 @@ // Send a capture lost event to the browser. /// void (CEF_CALLBACK *send_capture_lost_event)(struct _cef_browser_t* self); + + // VALVE BUILD + /// + // true (1) if the browser has something valid in it + /// + void (CEF_CALLBACK *paint)(struct _cef_browser_t* self); + int (CEF_CALLBACK *is_visually_non_empty)(struct _cef_browser_t* self); + + // is the browser control allowed to draw scrollbars + void (CEF_CALLBACK *set_show_scroll_bars)(struct _cef_browser_t* self, + int bShow); + + // if I was the horizontal scrollbar how big would I be? + void (CEF_CALLBACK *horizontal_scroll_bar_size)(struct _cef_browser_t* self, + int* x, int* y, int* wide, int* tall); + + // if I was the vertical scrollbar how big would I be? + void (CEF_CALLBACK *vertical_scroll_bar_size)(struct _cef_browser_t* self, + int* x, int* y, int* wide, int* tall); + + // amount of scroll into scroll max + int (CEF_CALLBACK *horizontal_scroll)(struct _cef_browser_t* self); + + // amount of scroll into scroll max + int (CEF_CALLBACK *vertical_scroll)(struct _cef_browser_t* self); + + // amount of scroll into scroll max + int (CEF_CALLBACK *horizontal_scroll_max)(struct _cef_browser_t* self); + + // amount of scroll into scroll max + int (CEF_CALLBACK *vertical_scroll_max)(struct _cef_browser_t* self); + + // amount of scroll into scroll max + int (CEF_CALLBACK *is_horizontal_scroll_bar_visible)( + struct _cef_browser_t* self); + + // amount of scroll into scroll max + int (CEF_CALLBACK *is_veritcal_scroll_bar_visible)( + struct _cef_browser_t* self); + + // amount of scroll into scroll max + void (CEF_CALLBACK *set_horizontal_scroll)(struct _cef_browser_t* self, + int scroll); + + // amount of scroll into scroll max + void (CEF_CALLBACK *set_vertical_scroll)(struct _cef_browser_t* self, + int scroll); + void (CEF_CALLBACK *set_user_agent)(struct _cef_browser_t* self, + const cef_string_t* pchUserAgent); + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t (CEF_CALLBACK *get_link_at_position)( + struct _cef_browser_t* self, int x, int y); + int (CEF_CALLBACK *zoom_to_element_at)(struct _cef_browser_t* self, int x, + int y, int max_width, int max_height, int min_block_width, + int min_block_height, cef_rect_t* initialRect, cef_rect_t* finalRect); } cef_browser_t; Index: include/capi/cef_life_span_handler_capi.h =================================================================== --- include/capi/cef_life_span_handler_capi.h (revision 465) +++ include/capi/cef_life_span_handler_capi.h (working copy) @@ -104,6 +104,16 @@ /// void (CEF_CALLBACK *on_before_close)(struct _cef_life_span_handler_t* self, struct _cef_browser_t* browser); + + /// + // Called just before a new tab is created + /// + int (CEF_CALLBACK *on_new_tab)(struct _cef_life_span_handler_t* self, + struct _cef_browser_t* parentBrowser, + const struct _cef_popup_features_t* popupFeatures, + struct _cef_window_info_t* windowInfo, const cef_string_t* url, + int bForeground, struct _cef_client_t** client, + struct _cef_browser_settings_t* settings); } cef_life_span_handler_t; Index: include/capi/cef_load_handler_capi.h =================================================================== --- include/capi/cef_load_handler_capi.h (revision 465) +++ include/capi/cef_load_handler_capi.h (working copy) @@ -76,7 +76,7 @@ /// void (CEF_CALLBACK *on_load_end)(struct _cef_load_handler_t* self, struct _cef_browser_t* browser, struct _cef_frame_t* frame, - int httpStatusCode); + int httpStatusCode, struct _cef_request_t* req); /// // Called when the browser fails to load a resource. |errorCode| is the error Index: include/capi/cef_render_handler_capi.h =================================================================== --- include/capi/cef_render_handler_capi.h (revision 465) +++ include/capi/cef_render_handler_capi.h (working copy) @@ -108,6 +108,22 @@ /// void (CEF_CALLBACK *on_cursor_change)(struct _cef_render_handler_t* self, struct _cef_browser_t* browser, cef_cursor_handle_t cursor); + + /// + // Called when the browser window's has a custom cursor set + /// + int (CEF_CALLBACK *on_set_cursor)(struct _cef_render_handler_t* self, + struct _cef_browser_t* browser, enum cef_handler_cursortype_t type, + const void* pchIconData, int iWide, int iTall, int xHotSpot, + int yHotSpot); + + /// + // Called when the browser window's has a custom cursor set + /// + int (CEF_CALLBACK *on_file_open_dialog)(struct _cef_render_handler_t* self, + struct _cef_browser_t* browser, bool bMultiSelect, const cef_string_t*default_title, + const cef_string_t*default_file, void *pCallback ); + } cef_render_handler_t; Index: include/capi/cef_request_capi.h =================================================================== --- include/capi/cef_request_capi.h (revision 465) +++ include/capi/cef_request_capi.h (working copy) @@ -137,6 +137,19 @@ /// void (CEF_CALLBACK *set_first_party_for_cookies)(struct _cef_request_t* self, const cef_string_t* url); + + /// + // Set the SSL state for this request + /// + void (CEF_CALLBACK *set_security_details)(struct _cef_request_t* self, + struct _cef_security_details_t* details); + + // true (1) if this was over a SSL connection + int (CEF_CALLBACK *bis_secure_request)(struct _cef_request_t* self); + + // true (1) if this was over a SSL connection + struct _cef_security_details_t* (CEF_CALLBACK *security_details)( + struct _cef_request_t* self); } cef_request_t; @@ -254,6 +267,40 @@ CEF_EXPORT cef_post_data_element_t* cef_post_data_element_create(); +// Structure used to represent the security settings for a page +typedef struct _cef_security_details_t { + /// + // Base structure. + /// + cef_base_t base; + + // return if the page is secure + int (CEF_CALLBACK *bis_secure)(struct _cef_security_details_t* self); + + // true (1) if there is a problem with the certificate + int (CEF_CALLBACK *bhas_cert_error)(struct _cef_security_details_t* self); + + // the common name in the SSL cert, usually the hostname + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t (CEF_CALLBACK *pch_cert_common_name)( + struct _cef_security_details_t* self); + + // the name of the issuer + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t (CEF_CALLBACK *pch_cert_issuer)( + struct _cef_security_details_t* self); + + // the unix time of the expiry for this cert + time_t (CEF_CALLBACK *tcert_expiry)(struct _cef_security_details_t* self); + + // the number of bits used by the cert, -1 if unknown + int (CEF_CALLBACK *ncert_bits)(struct _cef_security_details_t* self); + + // true (1) if they was an EV cert + int (CEF_CALLBACK *bis_evcert)(struct _cef_security_details_t* self); +} cef_security_details_t; + + #ifdef __cplusplus } #endif Index: include/capi/cef_request_handler_capi.h =================================================================== --- include/capi/cef_request_handler_capi.h (revision 465) +++ include/capi/cef_request_handler_capi.h (working copy) @@ -55,6 +55,7 @@ /// cef_base_t base; + // VALVE BUILD /// // Called on the UI thread before browser navigation. Return true (1) to // cancel the navigation or false (0) to allow the navigation to proceed. @@ -62,8 +63,11 @@ int (CEF_CALLBACK *on_before_browse)(struct _cef_request_handler_t* self, struct _cef_browser_t* browser, struct _cef_frame_t* frame, struct _cef_request_t* request, enum cef_handler_navtype_t navType, - int isRedirect); + int isRedirect, int isNewTabRequest); + + // VALVE BUILD + /// // Called on the IO thread before a resource is loaded. To allow the resource // to load normally return false (0). To redirect the resource to a new url Index: include/capi/cef_v8_capi.h =================================================================== --- include/capi/cef_v8_capi.h (revision 465) +++ include/capi/cef_v8_capi.h (working copy) @@ -562,7 +562,7 @@ /// // Create a new cef_v8value_t object of type object with optional user data and // accessor. This function should only be called from within the scope of a -// cef_v8context_tHandler, cef_v8handler_t or cef_v8accessor_t callback, or in +// cef_v8context_handler_t, cef_v8handler_t or cef_v8accessor_t callback, or in // combination with calling enter() and exit() on a stored cef_v8context_t // reference. /// @@ -571,7 +571,7 @@ /// // Create a new cef_v8value_t object of type array. This function should only be -// called from within the scope of a cef_v8context_tHandler, cef_v8handler_t or +// called from within the scope of a cef_v8context_handler_t, cef_v8handler_t or // cef_v8accessor_t callback, or in combination with calling enter() and exit() // on a stored cef_v8context_t reference. /// @@ -579,7 +579,7 @@ /// // Create a new cef_v8value_t object of type function. This function should only -// be called from within the scope of a cef_v8context_tHandler, cef_v8handler_t +// be called from within the scope of a cef_v8context_handler_t, cef_v8handler_t // or cef_v8accessor_t callback, or in combination with calling enter() and // exit() on a stored cef_v8context_t reference. /// Index: include/cef_app.h =================================================================== --- include/cef_app.h (revision 465) +++ include/cef_app.h (working copy) @@ -51,7 +51,7 @@ // that it failed. /// /*--cef(revision_check,optional_param=application)--*/ -bool CefInitialize(const CefSettings& settings, CefRefPtr application); +bool CefInitialize(const CefSettings& settings, CefRefPtr application, const CefString pchResourceDLL ); /// // This function should be called on the main application thread to shut down Index: include/cef_base.h =================================================================== --- include/cef_base.h (revision 465) +++ include/cef_base.h (working copy) @@ -39,6 +39,7 @@ #define CEF_INCLUDE_CEF_BASE_H_ #pragma once +#define VALVE_BUILD #include "include/internal/cef_build.h" #include "include/internal/cef_ptr.h" #include "include/internal/cef_types_wrappers.h" Index: include/cef_browser.h =================================================================== --- include/cef_browser.h (revision 465) +++ include/cef_browser.h (working copy) @@ -330,6 +330,68 @@ /// /*--cef()--*/ virtual void SendCaptureLostEvent() =0; + + // VALVE BUILD + /// + // true if the browser has something valid in it + /// + /*--cef()--*/ + virtual void Paint() = 0; + + /*--cef()--*/ + virtual bool IsVisuallyNonEmpty() = 0; + + // is the browser control allowed to draw scrollbars + /*--cef()--*/ + virtual void SetShowScrollBars( bool bShow ) = 0; + + // if I was the horizontal scrollbar how big would I be? + /*--cef()--*/ + virtual void HorizontalScrollBarSize( int& x, int& y, int& wide, int& tall) = 0; + + // if I was the vertical scrollbar how big would I be? + /*--cef()--*/ + virtual void VerticalScrollBarSize( int& x, int& y, int& wide, int& tall) = 0; + + // amount of scroll into scroll max + /*--cef()--*/ + virtual int HorizontalScroll() = 0; + + // amount of scroll into scroll max + /*--cef()--*/ + virtual int VerticalScroll() = 0; + + // amount of scroll into scroll max + /*--cef()--*/ + virtual int HorizontalScrollMax() = 0; + // amount of scroll into scroll max + /*--cef()--*/ + virtual int VerticalScrollMax() = 0; + + // amount of scroll into scroll max + /*--cef()--*/ + virtual bool IsHorizontalScrollBarVisible() = 0; + // amount of scroll into scroll max + /*--cef()--*/ + virtual bool IsVeritcalScrollBarVisible() = 0; + + // amount of scroll into scroll max + /*--cef()--*/ + virtual void SetHorizontalScroll( int scroll ) = 0; + // amount of scroll into scroll max + /*--cef()--*/ + virtual void SetVerticalScroll( int scroll ) = 0; + + /*--cef()--*/ + virtual void SetUserAgent( const CefString& pchUserAgent ) = 0; + + /*--cef()--*/ + virtual const CefString GetLinkAtPosition( int x, int y ) = 0; + + /*--cef()--*/ + virtual int zoomToElementAt( int x, int y,int max_width, int max_height, int min_block_width, int min_block_height, CefRect& initialRect, CefRect& finalRect ) = 0; + +// VALVE BUILD }; #endif // CEF_INCLUDE_CEF_BROWSER_H_ Index: include/cef_life_span_handler.h =================================================================== --- include/cef_life_span_handler.h (revision 465) +++ include/cef_life_span_handler.h (working copy) @@ -100,6 +100,20 @@ /// /*--cef()--*/ virtual void OnBeforeClose(CefRefPtr browser) {} + + + /// + // Called just before a new tab is created + /// + /*--cef(optional_param=url)--*/ + virtual bool OnNewTab(CefRefPtr parentBrowser, + const CefPopupFeatures& popupFeatures, + CefWindowInfo& windowInfo, + const CefString& url, + bool bForeground, + CefRefPtr& client, + CefBrowserSettings& settings ) { return false; } + }; #endif // CEF_INCLUDE_CEF_LIFE_SPAN_HANDLER_H_ Index: include/cef_linux.h =================================================================== --- include/cef_linux.h (revision 0) +++ include/cef_linux.h (working copy) @@ -0,0 +1,202 @@ +// Copyright (c) 2008 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +#ifndef _CEF_LINUX_H +#define _CEF_LINUX_H + +#if defined(__linux__) +#include +#include "cef_types_linux.h" + +// Atomic increment and decrement. +inline long CefAtomicIncrement( long volatile *pDest ) +{ + return __sync_fetch_and_add( pDest, 1 ) + 1; +} + +inline long CefAtomicDecrement( long volatile *pDest ) +{ + return __sync_fetch_and_sub( pDest, 1 ) - 1; +} + + +// Critical section wrapper. +class CefCriticalSection +{ +public: + CefCriticalSection() + { + // In release, go with the default lock attributes. + pthread_mutexattr_init( &m_Attr ); + pthread_mutexattr_settype( &m_Attr, PTHREAD_MUTEX_RECURSIVE ); + pthread_mutex_init(&os_lock_, &m_Attr); + } + ~CefCriticalSection() + { + pthread_mutex_destroy(&os_lock_); + } + void Lock() + { + pthread_mutex_lock(&os_lock_); + } + void Unlock() + { + pthread_mutex_unlock(&os_lock_); + } +private: + pthread_mutex_t os_lock_; + pthread_mutexattr_t m_Attr; +}; + +// Class representing window information. +class CefWindowInfo : public cef_window_info_t +{ +public: + CefWindowInfo() + { + Init(); + } + ~CefWindowInfo() + { + if(m_windowName) + cef_string_free(m_windowName); + } + + CefWindowInfo(const CefWindowInfo& r) + { + Init(); + *this = r; + } + CefWindowInfo(const cef_window_info_t& r) + { + Init(); + *this = r; + } + + void Init() + { + m_windowName = NULL; + m_x = 0; + m_y = 0; + m_nWidth = 0; + m_nHeight = 0; + m_bPopupWindow = FALSE; + } + + CefWindowInfo& operator=(const CefWindowInfo& r) + { + return operator=(static_cast(r)); + } + CefWindowInfo& operator=(const cef_window_info_t& r) + { + if(m_windowName) + cef_string_free(m_windowName); + if(r.m_windowName) + m_windowName = cef_string_alloc(r.m_windowName); + else + m_windowName = NULL; + m_x = r.m_x; + m_y = r.m_y; + m_nWidth = r.m_nWidth; + m_nHeight = r.m_nHeight; + return *this; + } + + void SetAsChild( int x, int y, int width, int height ) + { + m_x = x; + m_y = y; + m_nWidth = width; + m_nHeight = height; + } + + /* + void SetAsPopup(HWND hWndParent, const wchar_t *windowName) + { + m_dwStyle = WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN | WS_CLIPSIBLINGS; + m_hWndParent = hWndParent; + m_x = CW_USEDEFAULT; + m_y = CW_USEDEFAULT; + m_nWidth = CW_USEDEFAULT; + m_nHeight = CW_USEDEFAULT; + + if(m_windowName) + cef_string_free(m_windowName); + if(windowName) + m_windowName = cef_string_alloc(windowName); + else + m_windowName = NULL; + }*/ +}; + +// Class representing print context information. +class CefPrintInfo : public cef_print_info_t +{ +public: + CefPrintInfo() + { + Init(); + } + ~CefPrintInfo() + { + } + + CefPrintInfo(const CefPrintInfo& r) + { + Init(); + *this = r; + } + CefPrintInfo(const cef_print_info_t& r) + { + Init(); + *this = r; + } + + void Init() + { + m_Scale = 0; + } + + CefPrintInfo& operator=(const CefPrintInfo& r) + { + return operator=(static_cast(r)); + } + CefPrintInfo& operator=(const cef_print_info_t& r) + { + m_Scale = r.m_Scale; + return *this; + } +}; + +// Window handle. +#define CefWindowHandle cef_window_handle_t +#endif // _WIN32 + +#endif // _CEF_LINUX_H Index: include/cef_load_handler.h =================================================================== --- include/cef_load_handler.h (revision 465) +++ include/cef_load_handler.h (working copy) @@ -42,6 +42,7 @@ class CefBrowser; class CefFrame; +class CefRequest; /// // Implement this interface to handle events related to browser load status. The @@ -75,7 +76,7 @@ /*--cef()--*/ virtual void OnLoadEnd(CefRefPtr browser, CefRefPtr frame, - int httpStatusCode) {} + int httpStatusCode, CefRefPtr req) {} /// // Called when the browser fails to load a resource. |errorCode| is the error Index: include/cef_render_handler.h =================================================================== --- include/cef_render_handler.h (revision 465) +++ include/cef_render_handler.h (working copy) @@ -115,6 +115,25 @@ /*--cef()--*/ virtual void OnCursorChange(CefRefPtr browser, CefCursorHandle cursor) {} + + + // VALVE BUILD + typedef cef_handler_cursortype_t CursorType; + + /// + // Called when the browser window's has a custom cursor set + /// + /*--cef()--*/ + virtual bool OnSetCursor( CefRefPtr browser, const CursorType type, const void* pchIconData, int iWide, int iTall, int xHotSpot, int yHotSpot ) { return false; } + + + typedef cef_web_file_chooser_callback CefWebFileChooserCallback; + /// + // Called when the browser window's has a custom cursor set + /// + virtual bool OnFileOpenDialog( CefRefPtr browser, bool bMultiSelect, const CefString &default_title, const CefString &default_file, CefWebFileChooserCallback *pCallback ) { return false; } + + // VALVE BUILD }; #endif // CEF_INCLUDE_CEF_RENDER_HANDLER_H_ Index: include/cef_request.h =================================================================== --- include/cef_request.h (revision 465) +++ include/cef_request.h (working copy) @@ -44,6 +44,7 @@ class CefPostData; class CefPostDataElement; +class CefSecurityDetails; /// // Class used to represent a web request. The methods of this class may be @@ -138,6 +139,20 @@ /// /*--cef()--*/ virtual void SetFirstPartyForCookies(const CefString& url) =0; + + /// + // Set the SSL state for this request + /// + /*--cef()--*/ + virtual void SetSecurityDetails( CefRefPtr details) = 0; + + // true if this was over a SSL connection + /*--cef()--*/ + virtual bool BIsSecureRequest() = 0; + + // true if this was over a SSL connection + /*--cef()--*/ + virtual CefRefPtr SecurityDetails() = 0; }; @@ -252,4 +267,39 @@ virtual size_t GetBytes(size_t size, void* bytes) =0; }; + +// Class used to represent the security settings for a page +/*--cef(source=library)--*/ +class CefSecurityDetails : public virtual CefBase { +public: + // return if the page is secure + /*--cef()--*/ + virtual bool BIsSecure() =0; + + // true if there is a problem with the certificate + /*--cef()--*/ + virtual bool BHasCertError() = 0; + + // the common name in the SSL cert, usually the hostname + /*--cef()--*/ + virtual CefString PchCertCommonName() = 0; + + // the name of the issuer + /*--cef()--*/ + virtual CefString PchCertIssuer() = 0; + + // the unix time of the expiry for this cert + /*--cef()--*/ + virtual time_t TCertExpiry() = 0; + + // the number of bits used by the cert, -1 if unknown + /*--cef()--*/ + virtual int NCertBits() = 0; + + // true if they was an EV cert + /*--cef()--*/ + virtual bool BIsEVCert() = 0; +}; + + #endif // CEF_INCLUDE_CEF_REQUEST_H_ Index: include/cef_request_handler.h =================================================================== --- include/cef_request_handler.h (revision 465) +++ include/cef_request_handler.h (working copy) @@ -57,6 +57,8 @@ public: typedef cef_handler_navtype_t NavType; + + // VALVE BUILD /// // Called on the UI thread before browser navigation. Return true to cancel // the navigation or false to allow the navigation to proceed. @@ -66,7 +68,10 @@ CefRefPtr frame, CefRefPtr request, NavType navType, - bool isRedirect) { return false; } + bool isRedirect, + bool isNewTabRequest + ) { return false; } + // VALVE BUILD /// // Called on the IO thread before a resource is loaded. To allow the resource Index: include/cef_version.h =================================================================== --- include/cef_version.h (revision 0) +++ include/cef_version.h (working copy) @@ -0,0 +1,68 @@ +// Copyright (c) 2012 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// This file is generated by the make_version_header.py tool. +// + +#ifndef CEF_INCLUDE_CEF_VERSION_H_ +#define CEF_INCLUDE_CEF_VERSION_H_ + +#define CEF_REVISION 464 +#define COPYRIGHT_YEAR 2012 + +#define CHROME_VERSION_MAJOR 18 +#define CHROME_VERSION_MINOR 0 +#define CHROME_VERSION_BUILD 989 +#define CHROME_VERSION_PATCH 0 + +#define DO_MAKE_STRING(p) #p +#define MAKE_STRING(p) DO_MAKE_STRING(p) + +#ifndef APSTUDIO_HIDDEN_SYMBOLS + +#ifdef __cplusplus +extern "C" { +#endif + +#include "internal/cef_export.h" + +/// +// Returns the CEF build revision of the libcef library. +/// +CEF_EXPORT int cef_build_revision(); + +#ifdef __cplusplus +} +#endif + +#endif // APSTUDIO_HIDDEN_SYMBOLS + +#endif // CEF_INCLUDE_CEF_VERSION_H_ Index: include/internal/cef_build.h =================================================================== --- include/internal/cef_build.h (revision 465) +++ include/internal/cef_build.h (working copy) @@ -54,6 +54,10 @@ #error Please add support for your platform in cef_build.h #endif +// VALVE BUILD +#define VALVE_BUILD +// VALVE BUILD + // For access to standard POSIXish features, use OS_POSIX instead of a // more specific macro. #if defined(OS_MACOSX) || defined(OS_LINUX) Index: include/internal/cef_mac.h =================================================================== --- include/internal/cef_mac.h (revision 465) +++ include/internal/cef_mac.h (working copy) @@ -92,6 +92,7 @@ target->m_nWidth = src->m_nWidth; target->m_nHeight = src->m_nHeight; target->m_bHidden = src->m_bHidden; + target->m_bWindowRenderingDisabled = src->m_bWindowRenderingDisabled; } }; @@ -113,6 +114,11 @@ m_nHeight = height; m_bHidden = false; } + + void SetAsOffScreen() { + m_bWindowRenderingDisabled = true; + } + }; struct CefPrintInfoTraits { Index: include/internal/cef_string.h =================================================================== --- include/internal/cef_string.h (revision 465) +++ include/internal/cef_string.h (working copy) @@ -36,10 +36,10 @@ // If you change the default you MUST recompile all of CEF. // Build with the UTF8 string type as default. -// #define CEF_STRING_TYPE_UTF8 1 +#define CEF_STRING_TYPE_UTF8 1 // Build with the UTF16 string type as default. -#define CEF_STRING_TYPE_UTF16 1 +//#define CEF_STRING_TYPE_UTF16 1 // Build with the wide string type as default. // #define CEF_STRING_TYPE_WIDE 1 Index: include/internal/cef_tuple.h =================================================================== --- include/internal/cef_tuple.h (revision 465) +++ include/internal/cef_tuple.h (working copy) @@ -112,7 +112,7 @@ typedef A TypeA; Tuple1() {} - explicit Tuple1(typename TupleTraits::ParamType a) : a(a) {} + explicit Tuple1(typename TupleTraits::ParamType a_) : a(a_) {} A a; }; @@ -124,9 +124,9 @@ typedef B TypeB; Tuple2() {} - Tuple2(typename TupleTraits::ParamType a, - typename TupleTraits::ParamType b) - : a(a), b(b) { + Tuple2(typename TupleTraits::ParamType a_, + typename TupleTraits::ParamType b_) + : a(a_), b(b_) { } A a; @@ -141,10 +141,10 @@ typedef C TypeC; Tuple3() {} - Tuple3(typename TupleTraits::ParamType a, - typename TupleTraits::ParamType b, - typename TupleTraits::ParamType c) - : a(a), b(b), c(c) { + Tuple3(typename TupleTraits::ParamType a_, + typename TupleTraits::ParamType b_, + typename TupleTraits::ParamType c_) + : a(a_), b(b_), c(c_) { } A a; @@ -161,11 +161,11 @@ typedef D TypeD; Tuple4() {} - Tuple4(typename TupleTraits::ParamType a, - typename TupleTraits::ParamType b, - typename TupleTraits::ParamType c, - typename TupleTraits::ParamType d) - : a(a), b(b), c(c), d(d) { + Tuple4(typename TupleTraits::ParamType a_, + typename TupleTraits::ParamType b_, + typename TupleTraits::ParamType c_, + typename TupleTraits::ParamType d_) + : a(a_), b(b_), c(c_), d(d_) { } A a; @@ -184,12 +184,12 @@ typedef E TypeE; Tuple5() {} - Tuple5(typename TupleTraits::ParamType a, - typename TupleTraits::ParamType b, - typename TupleTraits::ParamType c, - typename TupleTraits::ParamType d, - typename TupleTraits::ParamType e) - : a(a), b(b), c(c), d(d), e(e) { + Tuple5(typename TupleTraits::ParamType a_, + typename TupleTraits::ParamType b_, + typename TupleTraits::ParamType c_, + typename TupleTraits::ParamType d_, + typename TupleTraits::ParamType e_) + : a(a_), b(b_), c(c_), d(d_), e(e_) { } A a; @@ -210,13 +210,13 @@ typedef F TypeF; Tuple6() {} - Tuple6(typename TupleTraits::ParamType a, - typename TupleTraits::ParamType b, - typename TupleTraits::ParamType c, - typename TupleTraits::ParamType d, - typename TupleTraits::ParamType e, - typename TupleTraits::ParamType f) - : a(a), b(b), c(c), d(d), e(e), f(f) { + Tuple6(typename TupleTraits::ParamType a_, + typename TupleTraits::ParamType b_, + typename TupleTraits::ParamType c_, + typename TupleTraits::ParamType d_, + typename TupleTraits::ParamType e_, + typename TupleTraits::ParamType f_) + : a(a_), b(b_), c(c_), d(d_), e(e_), f(f_) { } A a; @@ -239,14 +239,14 @@ typedef G TypeG; Tuple7() {} - Tuple7(typename TupleTraits::ParamType a, - typename TupleTraits::ParamType b, - typename TupleTraits::ParamType c, - typename TupleTraits::ParamType d, - typename TupleTraits::ParamType e, - typename TupleTraits::ParamType f, - typename TupleTraits::ParamType g) - : a(a), b(b), c(c), d(d), e(e), f(f), g(g) { + Tuple7(typename TupleTraits::ParamType a_, + typename TupleTraits::ParamType b_, + typename TupleTraits::ParamType c_, + typename TupleTraits::ParamType d_, + typename TupleTraits::ParamType e_, + typename TupleTraits::ParamType f_, + typename TupleTraits::ParamType g_) + : a(a_), b(b_), c(c_), d(d_), e(e_), f(f_), g(g_) { } A a; @@ -272,15 +272,15 @@ typedef H TypeH; Tuple8() {} - Tuple8(typename TupleTraits::ParamType a, - typename TupleTraits::ParamType b, - typename TupleTraits::ParamType c, - typename TupleTraits::ParamType d, - typename TupleTraits::ParamType e, - typename TupleTraits::ParamType f, - typename TupleTraits::ParamType g, - typename TupleTraits::ParamType h) - : a(a), b(b), c(c), d(d), e(e), f(f), g(g), h(h) { + Tuple8(typename TupleTraits::ParamType a_, + typename TupleTraits::ParamType b_, + typename TupleTraits::ParamType c_, + typename TupleTraits::ParamType d_, + typename TupleTraits::ParamType e_, + typename TupleTraits::ParamType f_, + typename TupleTraits::ParamType g_, + typename TupleTraits::ParamType h_) + : a(a_), b(b_), c(c_), d(d_), e(e_), f(f_), g(g_), h(h_) { } A a; Index: include/internal/cef_types.h =================================================================== --- include/internal/cef_types.h (revision 465) +++ include/internal/cef_types.h (working copy) @@ -47,6 +47,7 @@ #endif #include // For size_t +#include // The NSPR system headers define 64-bit as |long| when possible, except on // Mac OS X. In order to not have typedef mismatches, we do the same on LP64. @@ -611,10 +612,70 @@ ERR_UNEXPECTED_PROXY_AUTH = -323, ERR_EMPTY_RESPONSE = -324, ERR_RESPONSE_HEADERS_TOO_BIG = -325, + // VALVE + ERR_EMPTY_PROXY_LIST = -336, + ERR_CONNECTION_TIMED_OUT = -118, + // VALVE ERR_CACHE_MISS = -400, ERR_INSECURE_RESPONSE = -501, }; +// types of cursors webkit wants to display, needs to match WebCursorInfo in webkit\api\public\WebCursorInfo.h +enum cef_handler_cursortype_t +{ + TypePointer, + TypeCross, + TypeHand, + TypeIBeam, + TypeWait, + TypeHelp, + TypeEastResize, + TypeNorthResize, + TypeNorthEastResize, + TypeNorthWestResize, + TypeSouthResize, + TypeSouthEastResize, + TypeSouthWestResize, + TypeWestResize, + TypeNorthSouthResize, + TypeEastWestResize, + TypeNorthEastSouthWestResize, + TypeNorthWestSouthEastResize, + TypeColumnResize, + TypeRowResize, + TypeMiddlePanning, + TypeEastPanning, + TypeNorthPanning, + TypeNorthEastPanning, + TypeNorthWestPanning, + TypeSouthPanning, + TypeSouthEastPanning, + TypeSouthWestPanning, + TypeWestPanning, + TypeMove, + TypeVerticalText, + TypeCell, + TypeContextMenu, + TypeAlias, + TypeProgress, + TypeNoDrop, + TypeCopy, + TypeNone, + TypeNotAllowed, + TypeZoomIn, + TypeZoomOut, + TypeCustom +}; + +// callback for opening files +class cef_web_file_chooser_callback +{ +public: + virtual void OnFileChoose(const std::vector& file_names) = 0; +}; + + + /// // "Verb" of a drag-and-drop operation as negotiated between the source and // destination. These constants match their equivalents in WebCore's Index: include/internal/cef_types_linux.h =================================================================== --- include/internal/cef_types_linux.h (revision 465) +++ include/internal/cef_types_linux.h (working copy) @@ -35,7 +35,12 @@ #include "include/internal/cef_build.h" #if defined(OS_LINUX) +#if defined(STEAM) +typedef struct _GtkWidget GtkWidget; +#else #include +#endif +#include #include "include/internal/cef_string.h" #ifdef __cplusplus @@ -63,6 +68,14 @@ // Pointer for the new browser widget. cef_window_handle_t m_Widget; + + int m_x; + int m_y; + int m_nWidth; + int m_nHeight; + bool m_bWindowRenderingDisabled; + bool m_bPopupWindow; + } cef_window_info_t; /// Index: include/internal/cef_types_mac.h =================================================================== --- include/internal/cef_types_mac.h (revision 465) +++ include/internal/cef_types_mac.h (working copy) @@ -72,12 +72,15 @@ int m_nWidth; int m_nHeight; int m_bHidden; + int m_bPopupWindow; // NSView pointer for the parent view. cef_window_handle_t m_ParentView; // NSView pointer for the new browser view. cef_window_handle_t m_View; + // true if drawing into a texture + bool m_bWindowRenderingDisabled; } cef_window_info_t; /// Index: include/internal/cef_types_win.h =================================================================== --- include/internal/cef_types_win.h (revision 465) +++ include/internal/cef_types_win.h (working copy) @@ -79,6 +79,8 @@ // Set to true to enable transparent painting. BOOL m_bTransparentPainting; + BOOL m_bPopupWindow; + // Handle for the new browser window. cef_window_handle_t m_hWnd; } cef_window_info_t; Index: include/internal/cef_types_wrappers.h =================================================================== --- include/internal/cef_types_wrappers.h (revision 465) +++ include/internal/cef_types_wrappers.h (working copy) @@ -156,13 +156,13 @@ CefRect() : parent() {} CefRect(const cef_rect_t& r) : parent(r) {} // NOLINT(runtime/explicit) CefRect(const CefRect& r) : parent(r) {} // NOLINT(runtime/explicit) - CefRect(int x, int y, int width, int height) : parent() { - Set(x, y, width, height); + CefRect(int x_, int y_, int width_, int height_) : parent() { + Set(x_, y_, width_, height_); } bool IsEmpty() const { return width <= 0 || height <= 0; } - void Set(int x, int y, int width, int height) { - this->x = x, this->y = y, this->width = width, this->height = height; + void Set(int x_, int y_, int width_, int height_) { + this->x = x_, this->y = y_, this->width = width_, this->height = height_; } }; Index: libcef/browser_devtools_scheme_handler.cc =================================================================== --- libcef/browser_devtools_scheme_handler.cc (revision 465) +++ libcef/browser_devtools_scheme_handler.cc (working copy) @@ -1,132 +1,132 @@ -// Copyright (c) 2011 The Chromium Embedded Framework Authors. All rights -// reserved. Use of this source code is governed by a BSD-style license that can -// be found in the LICENSE file. - -#include "libcef/browser_devtools_scheme_handler.h" - -#include - -#include "include/cef_browser.h" -#include "include/cef_request.h" -#include "include/cef_response.h" -#include "include/cef_scheme.h" -#include "include/cef_stream.h" -#include "include/cef_url.h" -#include "libcef/browser_webkit_glue.h" - -#include "base/file_util.h" -#include "base/string_util.h" -#include "grit/devtools_resources_map.h" -#include "net/base/mime_util.h" -#include "ui/base/resource/resource_bundle.h" - -const char kChromeDevToolsScheme[] = "chrome-devtools"; -const char kChromeDevToolsHost[] = "devtools"; -const char kChromeDevToolsURL[] = "chrome-devtools://devtools/"; - -namespace { - -class DevToolsSchemeHandler : public CefSchemeHandler { - public: - DevToolsSchemeHandler(const std::string& path, - CefRefPtr reader, - int size) - : path_(path), reader_(reader), size_(size) { - } - - virtual bool ProcessRequest(CefRefPtr request, - CefRefPtr callback) - OVERRIDE { - callback->HeadersAvailable(); - return true; - } - - virtual void GetResponseHeaders(CefRefPtr response, - int64& response_length, - CefString& redirectUrl) OVERRIDE { - response_length = size_; - - std::string mime_type = "text/plain"; - if (net::GetMimeTypeFromFile(FilePath(CefString(path_)), &mime_type)) - response->SetMimeType(mime_type); - - response->SetStatus(200); - } - - virtual bool ReadResponse(void* data_out, - int bytes_to_read, - int& bytes_read, - CefRefPtr callback) - OVERRIDE { - bytes_read = reader_->Read(data_out, 1, bytes_to_read); - return (bytes_read > 0); - } - - virtual void Cancel() OVERRIDE { - } - - private: - std::string path_; - CefRefPtr reader_; - int size_; - - IMPLEMENT_REFCOUNTING(DevToolSSchemeHandler); -}; - -class DevToolsSchemeHandlerFactory : public CefSchemeHandlerFactory { - public: - DevToolsSchemeHandlerFactory() {} - - virtual CefRefPtr Create(CefRefPtr browser, - const CefString& scheme_name, - CefRefPtr request) - OVERRIDE { - // Remove the query component of the URL, if any. - CefURLParts parts; - CefParseURL(request->GetURL(), parts); - cef_string_clear(&parts.spec); - cef_string_clear(&parts.query); - CefString urlStr; - CefCreateURL(parts, urlStr); - - std::string url = urlStr; - const char* path = &url.c_str()[strlen(kChromeDevToolsURL)]; - - int size = -1; - CefRefPtr reader = GetStreamReader(path, size); - if (!reader.get()) - return NULL; - - return new DevToolsSchemeHandler(path, reader, size); - } - - CefRefPtr GetStreamReader(const char* path, int& size) { - // Create a stream for the grit resource. - for (size_t i = 0; i < kDevtoolsResourcesSize; ++i) { - if (base::strcasecmp(kDevtoolsResources[i].name, path) == 0) { - base::StringPiece piece = - webkit_glue::GetDataResource(kDevtoolsResources[i].value); - if (!piece.empty()) { - size = piece.size(); - return CefStreamReader::CreateForData(const_cast(piece.data()), - size); - } - } - } - - NOTREACHED() << "Missing DevTools resource: " << path; - return NULL; - } - - IMPLEMENT_REFCOUNTING(DevToolSSchemeHandlerFactory); -}; - -} // namespace - -// Register the DevTools scheme handler. -void RegisterDevToolsSchemeHandler(bool firstTime) { - if (firstTime) - CefRegisterCustomScheme(kChromeDevToolsScheme, true, false, true); - CefRegisterSchemeHandlerFactory(kChromeDevToolsScheme, kChromeDevToolsHost, - new DevToolsSchemeHandlerFactory()); -} +// Copyright (c) 2011 The Chromium Embedded Framework Authors. All rights +// reserved. Use of this source code is governed by a BSD-style license that can +// be found in the LICENSE file. + +#include "libcef/browser_devtools_scheme_handler.h" + +#include + +#include "include/cef_browser.h" +#include "include/cef_request.h" +#include "include/cef_response.h" +#include "include/cef_scheme.h" +#include "include/cef_stream.h" +#include "include/cef_url.h" +#include "libcef/browser_webkit_glue.h" + +#include "base/file_util.h" +#include "base/string_util.h" +#include "grit/devtools_resources_map.h" +#include "net/base/mime_util.h" +#include "ui/base/resource/resource_bundle.h" + +const char kChromeDevToolsScheme[] = "chrome-devtools"; +const char kChromeDevToolsHost[] = "devtools"; +const char kChromeDevToolsURL[] = "chrome-devtools://devtools/"; + +namespace { + +class DevToolsSchemeHandler : public CefSchemeHandler { + public: + DevToolsSchemeHandler(const std::string& path, + CefRefPtr reader, + int size) + : path_(path), reader_(reader), size_(size) { + } + + virtual bool ProcessRequest(CefRefPtr request, + CefRefPtr callback) + OVERRIDE { + callback->HeadersAvailable(); + return true; + } + + virtual void GetResponseHeaders(CefRefPtr response, + int64& response_length, + CefString& redirectUrl) OVERRIDE { + response_length = size_; + + std::string mime_type = "text/plain"; + if (net::GetMimeTypeFromFile(FilePath(CefString(path_)), &mime_type)) + response->SetMimeType(mime_type); + + response->SetStatus(200); + } + + virtual bool ReadResponse(void* data_out, + int bytes_to_read, + int& bytes_read, + CefRefPtr callback) + OVERRIDE { + bytes_read = reader_->Read(data_out, 1, bytes_to_read); + return (bytes_read > 0); + } + + virtual void Cancel() OVERRIDE { + } + + private: + std::string path_; + CefRefPtr reader_; + int size_; + + IMPLEMENT_REFCOUNTING(DevToolSSchemeHandler); +}; + +class DevToolsSchemeHandlerFactory : public CefSchemeHandlerFactory { + public: + DevToolsSchemeHandlerFactory() {} + + virtual CefRefPtr Create(CefRefPtr browser, + const CefString& scheme_name, + CefRefPtr request) + OVERRIDE { + // Remove the query component of the URL, if any. + CefURLParts parts; + CefParseURL(request->GetURL(), parts); + cef_string_clear(&parts.spec); + cef_string_clear(&parts.query); + CefString urlStr; + CefCreateURL(parts, urlStr); + + std::string url = urlStr; + const char* path = &url.c_str()[strlen(kChromeDevToolsURL)]; + + int size = -1; + CefRefPtr reader = GetStreamReader(path, size); + if (!reader.get()) + return NULL; + + return new DevToolsSchemeHandler(path, reader, size); + } + + CefRefPtr GetStreamReader(const char* path, int& size) { + // Create a stream for the grit resource. + for (size_t i = 0; i < kDevtoolsResourcesSize; ++i) { + if (base::strcasecmp(kDevtoolsResources[i].name, path) == 0) { + base::StringPiece piece = + webkit_glue::GetDataResource(kDevtoolsResources[i].value); + if (!piece.empty()) { + size = piece.size(); + return CefStreamReader::CreateForData(const_cast(piece.data()), + size); + } + } + } + + NOTREACHED() << "Missing DevTools resource: " << path; + return NULL; + } + + IMPLEMENT_REFCOUNTING(DevToolSSchemeHandlerFactory); +}; + +} // namespace + +// Register the DevTools scheme handler. +void RegisterDevToolsSchemeHandler(bool firstTime) { + if (firstTime) + CefRegisterCustomScheme(kChromeDevToolsScheme, true, false, true); + CefRegisterSchemeHandlerFactory(kChromeDevToolsScheme, kChromeDevToolsHost, + new DevToolsSchemeHandlerFactory()); +} Index: libcef/browser_devtools_scheme_handler.h =================================================================== --- libcef/browser_devtools_scheme_handler.h (revision 465) +++ libcef/browser_devtools_scheme_handler.h (working copy) @@ -1,16 +1,16 @@ -// Copyright (c) 2011 The Chromium Embedded Framework Authors. All rights -// reserved. Use of this source code is governed by a BSD-style license that can -// be found in the LICENSE file. - -#ifndef CEF_LIBCEF_BROWSER_DEVTOOLS_SCHEME_HANDLER_H_ -#define CEF_LIBCEF_BROWSER_DEVTOOLS_SCHEME_HANDLER_H_ -#pragma once - -extern const char kChromeDevToolsScheme[]; -extern const char kChromeDevToolsHost[]; -extern const char kChromeDevToolsURL[]; - -// Register the DevTools scheme handler. -void RegisterDevToolsSchemeHandler(bool firstTime); - -#endif // CEF_LIBCEF_BROWSER_DEVTOOLS_SCHEME_HANDLER_H_ +// Copyright (c) 2011 The Chromium Embedded Framework Authors. All rights +// reserved. Use of this source code is governed by a BSD-style license that can +// be found in the LICENSE file. + +#ifndef CEF_LIBCEF_BROWSER_DEVTOOLS_SCHEME_HANDLER_H_ +#define CEF_LIBCEF_BROWSER_DEVTOOLS_SCHEME_HANDLER_H_ +#pragma once + +extern const char kChromeDevToolsScheme[]; +extern const char kChromeDevToolsHost[]; +extern const char kChromeDevToolsURL[]; + +// Register the DevTools scheme handler. +void RegisterDevToolsSchemeHandler(bool firstTime); + +#endif // CEF_LIBCEF_BROWSER_DEVTOOLS_SCHEME_HANDLER_H_ Index: libcef/browser_impl.cc =================================================================== --- libcef/browser_impl.cc (revision 465) +++ libcef/browser_impl.cc (working copy) @@ -145,7 +145,7 @@ CefRefPtr browser( new CefBrowserImpl(windowInfo, settings, NULL, client)); - if (!static_cast(browser.get())->UIT_CreateBrowser(url)) + if (!static_cast(browser.get())->UIT_CreateBrowser(url, windowInfo.m_bPopupWindow)) return NULL; return browser; @@ -169,7 +169,8 @@ has_document_(false), is_dropping_(false), main_frame_(NULL), - unique_id_(0) + unique_id_(0), + m_bClosed( false ) // VALVE BUILD #if defined(OS_WIN) , opener_was_disabled_by_modal_loop_(false), internal_modal_message_loop_is_active_(false) @@ -186,6 +187,14 @@ } } +// VALVE BUILD +bool CefBrowserImpl::Close() +{ + m_bClosed = true; + return true; +} +// VALVE BUILD + void CefBrowserImpl::CloseBrowser() { CefThread::PostTask(CefThread::UI, FROM_HERE, NewRunnableMethod(this, &CefBrowserImpl::UIT_CloseBrowser)); @@ -275,6 +284,247 @@ } while (it != main_frame); } +/*void CefBrowserImpl::SupportsHWNDPainting( bool bSupported ) +{ + WebViewHost* host = UIT_GetWebViewHost(); + if ( host ) + host->set_supports_hwnd_painting( bSupported ); +} +*/ + +void CefBrowserImpl::GetBrowserSize( int &wide, int &tall ) +{ + WebViewHost *host = UIT_GetWebViewHost(); + wide = tall = 0; + + if ( host ) + { + if ( host->canvas() ) + { + wide = host->canvas()->getDevice()->width(); + tall = host->canvas()->getDevice()->height(); + } + } +} + + +void CefBrowserImpl::GetBrowserImage( char *pchImage, int wide, int tall ) +{ + WebViewHost *host = UIT_GetWebViewHost(); + if ( wide == 0 || tall == 0 ) + return; + if ( host && host->canvas() ) + { + DCHECK( wide == host->canvas()->getDevice()->width() ); + DCHECK( tall == host->canvas()->getDevice()->height() ); + const SkBitmap &bitmap = host->canvas()->getDevice()->accessBitmap(false); + const void *pixels = bitmap.getPixels(); + memcpy( pchImage, pixels, wide*tall*4); + } +} + +void CefBrowserImpl::SetBrowserSize( int wide, int tall ) +{ + WebViewHost *host = UIT_GetWebViewHost(); + if ( host ) + { + host->SetSize( wide, tall ); + } +} + + +void CefBrowserImpl::SetPopupSize( int wide, int tall ) +{ + WebWidgetHost *host = UIT_GetPopupHost(); + if ( host ) + { + host->SetSize( wide, tall ); + } +} + + +void CefBrowserImpl::Paint() +{ + WebViewHost *host = UIT_GetWebViewHost(); + if ( host ) + { + host->Paint(); + } + + WebWidgetHost *popup = UIT_GetPopupHost(); + if ( popup ) + { + popup->Paint(); + } +} + + +void CefBrowserImpl::SetShowScrollBars( bool bShow ) +{ + WebViewHost *host = UIT_GetWebViewHost(); + if ( host ) + { + host->SetShowScrollBars( bShow ); + } +} + +void CefBrowserImpl::HorizontalScrollBarSize( int &x, int &y, int &wide, int &tall) +{ + WebViewHost *host = UIT_GetWebViewHost(); + if ( host ) + { + host->HorizontalScrollBarSize( x, y, wide, tall ); + } +} + +void CefBrowserImpl::VerticalScrollBarSize( int &x, int &y, int &wide, int &tall) +{ + WebViewHost *host = UIT_GetWebViewHost(); + if ( host ) + { + host->VerticalScrollBarSize( x, y, wide, tall ); + } +} + +int CefBrowserImpl::HorizontalScroll() +{ + WebViewHost *host = UIT_GetWebViewHost(); + if ( host ) + { + return host->HorizontalScroll(); + } + return 0; +} + +int CefBrowserImpl::VerticalScroll() +{ + WebViewHost *host = UIT_GetWebViewHost(); + if ( host ) + { + return host->VerticalScroll(); + } + return 0; +} + +bool CefBrowserImpl::IsHorizontalScrollBarVisible() +{ + WebViewHost *host = UIT_GetWebViewHost(); + if ( host ) + { + return host->IsHorizontalScrollBarVisible(); + } + return false; +} +bool CefBrowserImpl::IsVeritcalScrollBarVisible() +{ + WebViewHost *host = UIT_GetWebViewHost(); + if ( host ) + { + return host->IsVeritcalScrollBarVisible(); + } + return false; +} + +int CefBrowserImpl::HorizontalScrollMax() +{ + WebViewHost *host = UIT_GetWebViewHost(); + if ( host ) + { + return host->HorizontalScrollMax(); + } + return 0; +} + +int CefBrowserImpl::VerticalScrollMax() +{ + WebViewHost *host = UIT_GetWebViewHost(); + if ( host ) + { + return host->VerticalScrollMax(); + } + return 0; +} + +void CefBrowserImpl::SetHorizontalScroll( int scroll ) +{ + WebViewHost *host = UIT_GetWebViewHost(); + if ( host ) + { + host->SetHorizontalScroll( scroll ); + int nWide, nTall; // now invalidate the window so we get a full repaint after the scroll + GetSize( PET_VIEW, nWide, nTall ); + Invalidate( CefRect( 0,0, nWide, nTall ) ); + } +} + +void CefBrowserImpl::SetVerticalScroll( int scroll ) +{ + WebViewHost *host = UIT_GetWebViewHost(); + if ( host ) + { + host->SetVerticalScroll( scroll ); + int nWide, nTall; // now invalidate the window so we get a full repaint after the scroll + GetSize( PET_VIEW, nWide, nTall ); + Invalidate( CefRect( 0,0, nWide, nTall ) ); + } +} + +void CefBrowserImpl::SetUserAgent( const CefString& pchUserAgent ) +{ + WebViewHost *host = UIT_GetWebViewHost(); + if ( host ) + { + host->SetUserAgent( pchUserAgent.c_str() ); + } +} + +bool CefBrowserImpl::IsVisuallyNonEmpty() +{ + WebViewHost *host = UIT_GetWebViewHost(); + if ( host ) + { + return host->IsVisuallyNonEmpty(); + } + return false; +} + + +const CefString CefBrowserImpl::GetLinkAtPosition( int x, int y ) +{ + WebViewHost *host = UIT_GetWebViewHost(); + if ( host ) + { + const char *pchURL = host->GetLinkAtPosition( x, y ) ; + if ( pchURL ) + return CefString(pchURL); + return CefString(); + } + return CefString(); +} + +int CefBrowserImpl::zoomToElementAt( int x, int y, int max_width, int max_height, int min_block_width, int min_block_height, CefRect &initialRect, CefRect &finalRect ) +{ + WebViewHost *host = UIT_GetWebViewHost(); + if ( host ) + { + WebKit::WebRect webRect_initialRect, webRect_finalRect; + int zoomlevel = host->zoomToElementAt( x, y, max_width, max_height, min_block_width, min_block_height, webRect_initialRect, webRect_finalRect ); + initialRect.x = webRect_initialRect.x; + initialRect.y = webRect_initialRect.y; + initialRect.width = webRect_initialRect.width; + initialRect.height = webRect_initialRect.height; + + finalRect.x = webRect_finalRect.x; + finalRect.y = webRect_finalRect.y; + finalRect.width = webRect_finalRect.width; + finalRect.height = webRect_finalRect.height; + + return zoomlevel; + } + return 100; +} + + void CefBrowserImpl::Find(int identifier, const CefString& searchText, bool forward, bool matchCase, bool findNext) { WebKit::WebFindOptions options; @@ -284,7 +534,7 @@ // Execute the request on the UI thread. CefThread::PostTask(CefThread::UI, FROM_HERE, NewRunnableMethod(this, - &CefBrowserImpl::UIT_Find, identifier, searchText, options)); + &CefBrowserImpl::UIT_Find, identifier, searchText, options) ); } void CefBrowserImpl::StopFinding(bool clearSelection) { @@ -650,7 +900,6 @@ REQUIRE_UIT(); CefRefPtr cef_frame; - if (frame->parent() == 0) { // Use the single main frame reference. cef_frame = GetMainCefFrame(); @@ -674,18 +923,19 @@ } WebFrame* CefBrowserImpl::UIT_GetWebFrame(CefRefPtr frame) { - REQUIRE_UIT(); + REQUIRE_UIT(); - WebView* view = UIT_GetWebView(); - if (!view) - return NULL; + WebView* view = UIT_GetWebView(); + if (!view) + return NULL; - CefString name = frame->GetName(); - if (name.empty()) - return view ->mainFrame(); - return view ->findFrameByName(string16(name)); + CefString name = frame->GetName(); + if (name.empty()) + return view ->mainFrame(); + return view ->findFrameByName(string16(name)); } + void CefBrowserImpl::UIT_DestroyBrowser() { if (client_.get()) { CefRefPtr handler = client_->GetLifeSpanHandler(); @@ -701,7 +951,7 @@ if (internal_modal_message_loop_is_active_) { MessageLoop* message_loop = MessageLoop::current(); message_loop->QuitNow(); - } + } } UIT_GetWebViewDelegate()->RevokeDragDrop(); @@ -714,7 +964,7 @@ if (dev_tools_agent_.get()) { BrowserDevToolsClient* client = dev_tools_agent_->client(); if (client) { - CefBrowserImpl* browser = client->browser(); + CefBrowserImpl* browser = client->browser(); // Destroy the client before freeing the agent. browser->UIT_DestroyDevToolsClient(); if (!_Context->shutting_down()) { @@ -736,11 +986,13 @@ // Remove the reference to the window handle. UIT_ClearMainWndHandle(); - // Remove the reference added in UIT_CreateBrowser(). - Release(); - + // VALVE BUILD, swapped order of below // Remove the browser from the list maintained by the context. _Context->RemoveBrowser(this); + + // Remove the reference added in UIT_CreateBrowser(). + Release(); // may cause the object to be deleted, so do last + // VALVE BUILD } void CefBrowserImpl::UIT_CloseBrowser() { @@ -837,7 +1089,7 @@ if (!gurl.is_valid() && !gurl.has_scheme()) { // Try to add "http://" at the beginning - std::string new_url = std::string("http://") + urlStr; + std::string new_url = std::string("http://") + urlStr; gurl = GURL(new_url); if (!gurl.is_valid()) return; @@ -866,6 +1118,10 @@ const CefString& script_url, int start_line) { REQUIRE_UIT(); +// VALVE BUILD + if ( m_bClosed ) + return; +// VALVE BUILD WebFrame* web_frame = UIT_GetWebFrame(frame); if (web_frame) { @@ -896,7 +1152,7 @@ // Get the right target frame for the entry. WebFrame* frame; if (!entry.GetTargetFrame().empty()) - frame = view->findFrameByName(string16(entry.GetTargetFrame())); + frame = view->findFrameByName( string16(entry.GetTargetFrame()) ); else frame = view->mainFrame(); @@ -1112,12 +1368,47 @@ // Don't pass the URL to UIT_CreateBrowser for popup windows or the URL will // be loaded twice. - if (!browser->UIT_CreateBrowser(CefString())) + if (!browser->UIT_CreateBrowser(CefString(), true)) return NULL; return browser; } +// VALVE BUILD +CefRefPtr CefBrowserImpl::UIT_CreateNewTab(const CefString& url, const CefPopupFeatures &popupFeatures, bool bForeground ) +{ + REQUIRE_UIT(); + CefWindowInfo info; +#if defined(OS_WIN) + info.SetAsPopup(NULL, url.c_str()); +#endif + info.m_nWidth = popupFeatures.width; + info.m_nHeight = popupFeatures.height; + info.m_x = popupFeatures.x; + info.m_y = popupFeatures.y; + + CefRefPtr client = client_; + + // Start with the current browser window's settings. + CefBrowserSettings settings(settings_); + + if (client_.get()) { + CefRefPtr handler = client_->GetLifeSpanHandler(); + std::wstring newUrl = url; + + if( handler.get() ) + { + // Give the handler an opportunity to modify window attributes, handler, + // or cancel the window creation. + if( handler->OnNewTab( this, popupFeatures, info, newUrl, bForeground, client, settings ) ) + return NULL; + } + } + + return NULL; +} +// VALVE BUILD + WebKit::WebWidget* CefBrowserImpl::UIT_CreatePopupWidget() { REQUIRE_UIT(); @@ -1536,7 +1827,60 @@ } } +/*double CefBrowserImpl::GetZoomLevel() +{ + WebKit::WebFrame* web_frame = GetWebFrame(this->GetMainFrame()); + if(web_frame && web_frame->view()) + return web_frame->view()->zoomLevel(); + + return 0.0; +} + +void CefBrowserImpl::SetZoomLevel(double zoomLevel) +{ + CefRefPtr frame = this->GetMainFrame(); + frame->AddRef(); + CefThread::PostTask(CefThread::UI, FROM_HERE, NewRunnableMethod(this, + &CefBrowserImpl::UIT_SetZoomLevel, frame.get(), zoomLevel)); +} + +void CefBrowserImpl::UIT_SetZoomLevel(CefFrame* frame, double zoomLevel) +{ + REQUIRE_UIT(); + WebKit::WebFrame* web_frame = GetWebFrame(frame); + + if(web_frame && web_frame->view()) { + web_frame->view()->setZoomFactor( zoomLevel ); + ZoomMap::GetInstance()->set(web_frame->url(), zoomLevel); + } + + frame->Release(); +}*/ + +void CefBrowserImpl::SetSecurityDetails( const char *pchURL, std::string security_info ) +{ + SecurityInfoMap::iterator it = security_info_.find(pchURL); + if(it != security_info_.end()) + it->second = security_info; + else { + security_info_.insert(std::make_pair(pchURL, security_info)); + } + + +} + +void CefBrowserImpl::GetSecurityDetails( const char *pchURL, std::string &security_info ) +{ + SecurityInfoMap::iterator it = security_info_.find(pchURL); + if(it != security_info_.end()) + { + security_info = it->second; + security_info_.erase( it ); + } +} + + // CefFrameImpl CefFrameImpl::CefFrameImpl(CefBrowserImpl* browser, const CefString& name) Index: libcef/browser_impl.h =================================================================== --- libcef/browser_impl.h (revision 465) +++ libcef/browser_impl.h (working copy) @@ -34,11 +34,12 @@ } namespace WebKit { class WebView; +class WebWidget; } + #define BUFFER_SIZE 32768 - // Implementation of CefBrowser. class CefBrowserImpl : public CefBrowser { public: @@ -113,6 +114,32 @@ virtual void SendFocusEvent(bool setFocus) OVERRIDE; virtual void SendCaptureLostEvent() OVERRIDE; + virtual void GetBrowserSize( int &wide, int &tall ); + virtual void GetBrowserImage( char *pchImage, int wide, int tall ); + virtual void SetBrowserSize( int wide, int tall ); + virtual void SetPopupSize( int wide, int tall ); + virtual void Paint(); +// virtual void SetBrowserGlobalPosition( int x, int y ); + // virtual void SetPopupGlobalPosition( int x, int y ); + //virtual void RemoveBrowser(); + virtual void SetShowScrollBars( bool bShow ); + virtual void HorizontalScrollBarSize( int &x, int &y, int &wide, int &tall); + virtual void VerticalScrollBarSize( int &x, int &y, int &wide, int &tall); + virtual int HorizontalScroll(); + virtual int VerticalScroll(); + virtual int HorizontalScrollMax(); + virtual int VerticalScrollMax(); + virtual bool IsHorizontalScrollBarVisible(); + virtual bool IsVeritcalScrollBarVisible(); + virtual void SetHorizontalScroll( int scroll ); + virtual void SetVerticalScroll( int scroll ); + virtual void SetUserAgent( const CefString& pchUserAgent ); + virtual bool IsVisuallyNonEmpty(); + virtual const CefString GetLinkAtPosition( int x, int y ); + virtual int zoomToElementAt( int x, int y, int max_width, int max_height, int min_block_width, int min_block_height, CefRect &initialRect, CefRect &finalRect ); + virtual bool Close(); + + // Frame-related methods void Undo(CefRefPtr frame); void Redo(CefRefPtr frame); @@ -229,7 +256,7 @@ } // Create the native browser window and populate browser members. - bool UIT_CreateBrowser(const CefString& url); + bool UIT_CreateBrowser(const CefString& url, bool bPopup); // Destroy the browser members. This method should only be called after the // native browser window is not longer processing messages. @@ -279,6 +306,9 @@ const CefPopupFeatures& features); WebKit::WebWidget* UIT_CreatePopupWidget(); void UIT_ClosePopupWidget(); + // VALVE BUILD + CefRefPtr UIT_CreateNewTab(const CefString& url, const CefPopupFeatures &info, bool bForeground ); + // VALVE BUILD void UIT_Show(WebKit::WebNavigationPolicy policy); @@ -320,6 +350,9 @@ CefTrackObject* tracked_object); void UIT_BeforeFrameClosed(WebKit::WebFrame* frame); + virtual void SetSecurityDetails( const char *pchURL, std::string security_info ); + virtual void GetSecurityDetails( const char *pchURL, std::string &security_info ); + // These variables are read-only. const CefBrowserSettings& settings() const { return settings_; } const FilePath& file_system_root() const { return file_system_root_.path(); } @@ -404,6 +437,9 @@ // Unique browser ID assigned by the context. int unique_id_; + bool m_bClosed; + typedef std::map SecurityInfoMap; + SecurityInfoMap security_info_; // A temporary directory for FileSystem API. ScopedTempDir file_system_root_; Index: libcef/browser_impl_gtk.cc =================================================================== --- libcef/browser_impl_gtk.cc (revision 465) +++ libcef/browser_impl_gtk.cc (working copy) @@ -50,7 +50,7 @@ window_info_.m_Widget = NULL; } -bool CefBrowserImpl::UIT_CreateBrowser(const CefString& url) { +bool CefBrowserImpl::UIT_CreateBrowser(const CefString& url, bool bPopup) { REQUIRE_UIT(); Lock(); Index: libcef/browser_impl_linux.cc =================================================================== --- libcef/browser_impl_linux.cc (revision 0) +++ libcef/browser_impl_linux.cc (working copy) @@ -0,0 +1 @@ +browser_impl_win.cc \ No newline at end of file Index: libcef/browser_impl_mac.mm =================================================================== --- libcef/browser_impl_mac.mm (revision 465) +++ libcef/browser_impl_mac.mm (working copy) @@ -16,6 +16,8 @@ #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" #include "webkit/glue/webpreferences.h" +#include "osx_leopard_template_workaround.cpp" + using WebKit::WebRect; using WebKit::WebSize; @@ -29,8 +31,7 @@ } bool CefBrowserImpl::IsWindowRenderingDisabled() { - // TODO(port): Add support for off-screen rendering. - return false; + return (window_info_.m_bWindowRenderingDisabled ? true : false); } gfx::NativeView CefBrowserImpl::UIT_GetMainWndHandle() { @@ -40,10 +41,11 @@ void CefBrowserImpl::UIT_ClearMainWndHandle() { REQUIRE_UIT(); - window_info_.m_View = NULL; + if (!window_info_.m_bWindowRenderingDisabled) + window_info_.m_View = NULL; } -bool CefBrowserImpl::UIT_CreateBrowser(const CefString& url) { +bool CefBrowserImpl::UIT_CreateBrowser(const CefString& url, bool bPopup ) { REQUIRE_UIT(); Lock(); @@ -57,42 +59,51 @@ dev_tools_agent_.reset(new BrowserDevToolsAgent()); NSWindow* newWnd = nil; - + NSView* parentView = window_info_.m_ParentView; gfx::Rect contentRect(window_info_.m_x, window_info_.m_y, - window_info_.m_nWidth, window_info_.m_nHeight); - if (parentView == nil) { - // Create a new window. - NSRect screen_rect = [[NSScreen mainScreen] visibleFrame]; - NSRect window_rect = {{window_info_.m_x, - screen_rect.size.height - window_info_.m_y}, - {window_info_.m_nWidth, window_info_.m_nHeight}}; - if (window_rect.size.width == 0) - window_rect.size.width = 750; - if (window_rect.size.height == 0) - window_rect.size.height = 750; - contentRect.SetRect(0, 0, window_rect.size.width, window_rect.size.height); + window_info_.m_nWidth, window_info_.m_nHeight); + if (!window_info_.m_bWindowRenderingDisabled) { + if (parentView == nil) { + // Create a new window. + NSRect screen_rect = [[NSScreen mainScreen] visibleFrame]; + NSRect window_rect = {{window_info_.m_x, + screen_rect.size.height - window_info_.m_y}, + {window_info_.m_nWidth, window_info_.m_nHeight}}; + if (window_rect.size.width == 0) + window_rect.size.width = 750; + if (window_rect.size.height == 0) + window_rect.size.height = 750; + contentRect.SetRect(0, 0, window_rect.size.width, window_rect.size.height); - newWnd = [[NSWindow alloc] - initWithContentRect:window_rect - styleMask:(NSTitledWindowMask | - NSClosableWindowMask | - NSMiniaturizableWindowMask | - NSResizableWindowMask | - NSUnifiedTitleAndToolbarWindowMask ) - backing:NSBackingStoreBuffered - defer:NO]; - parentView = [newWnd contentView]; - window_info_.m_ParentView = parentView; + newWnd = [[NSWindow alloc] + initWithContentRect:window_rect + styleMask:(NSTitledWindowMask | + NSClosableWindowMask | + NSMiniaturizableWindowMask | + NSResizableWindowMask | + NSUnifiedTitleAndToolbarWindowMask ) + backing:NSBackingStoreBuffered + defer:NO]; + parentView = [newWnd contentView]; + window_info_.m_ParentView = parentView; + } + } else { + // Create a new paint delegate. + paint_delegate_.reset(new PaintDelegate(this)); } - + WebPreferences prefs; BrowserToWebSettings(settings_, prefs); - + // VALVE BUILD + if ( bPopup ) + prefs.allow_scripts_to_close_windows = true; + // VALVE BUILD + // Create the webview host object webviewhost_.reset( WebViewHost::Create(parentView, contentRect, delegate_.get(), - NULL, dev_tools_agent_.get(), prefs)); + paint_delegate_.get(), dev_tools_agent_.get(), prefs)); if (!settings_.developer_tools_disabled) dev_tools_agent_->SetWebView(webviewhost_->webview()); @@ -101,9 +112,11 @@ browserView.browser = this; window_info_.m_View = browserView; - if (!settings_.drag_drop_disabled) - [browserView registerDragDrop]; - + if (!window_info_.m_bWindowRenderingDisabled) { + if (!settings_.drag_drop_disabled) + [browserView registerDragDrop]; + } + Unlock(); if (newWnd != nil && !window_info_.m_bHidden) { @@ -130,20 +143,48 @@ if (!host) return; +#ifdef VALVE_BUILD + UIT_GetWebView()->setFocus(enable); +#else NSView* view = host->view_handle(); if (!view) return; if (enable) [[view window] makeFirstResponder:view]; +#endif } + +static void WriteTextToFile(const std::string& title, + const std::string& data, + const std::string& file_path) +{ + FILE* fp = fopen( file_path.c_str(), "wt"); + if (!fp) + return; + fwrite(title.c_str(), 1, title.size(), fp); + fwrite("\n", 1, 2, fp ); + fwrite(data.c_str(), 1, data.size(), fp); + fclose(fp); +} + bool CefBrowserImpl::UIT_ViewDocumentString(WebKit::WebFrame *frame) { REQUIRE_UIT(); - // TODO(port): Add implementation. - NOTIMPLEMENTED(); - return false; + std::string url = frame->name().utf8(); + std::string markup = frame->contentAsMarkup().utf8(); + + char sztmp[L_tmpnam]; + if ( tmpnam( sztmp ) ) + { + strcat( sztmp, ".txt" ); + WriteTextToFile(url, markup, sztmp); + char szopen[L_tmpnam + 16]; + snprintf( szopen, sizeof( szopen ), "open -t \"%s\"", sztmp ); + return ( system( szopen ) >= 0 ); + } + return false; } void CefBrowserImpl::UIT_PrintPage(int page_number, int total_pages, Index: libcef/browser_impl_win.cc =================================================================== --- libcef/browser_impl_win.cc (revision 465) +++ libcef/browser_impl_win.cc (working copy) @@ -5,11 +5,22 @@ #include "libcef/browser_impl.h" +#if defined(OS_WIN) #include +#elif defined(OS_MACOSX) +#include "base/mac_util.h" +#elif defined(OS_LINUX) +#include "base/linux_util.h" +#else +#error +#endif +#include "webkit/glue/webpreferences.h" +#if defined(OS_WIN) #include #include #include #include +#endif #include "libcef/cef_context.h" #include "libcef/browser_settings.h" @@ -33,22 +44,22 @@ namespace { -bool IsAeroGlassEnabled() { - if (base::win::GetVersion() < base::win::VERSION_VISTA) - return false; + bool IsAeroGlassEnabled() { + if (base::win::GetVersion() < base::win::VERSION_VISTA) + return false; - BOOL enabled = FALSE; - return SUCCEEDED(DwmIsCompositionEnabled(&enabled)) && enabled; -} + BOOL enabled = FALSE; + return SUCCEEDED(DwmIsCompositionEnabled(&enabled)) && enabled; + } -void SetAeroGlass(HWND hWnd) { - if (!IsAeroGlassEnabled()) - return; + void SetAeroGlass(HWND hWnd) { + if (!IsAeroGlassEnabled()) + return; - // Make the whole window transparent. - MARGINS mgMarInset = { -1, -1, -1, -1 }; - DwmExtendFrameIntoClientArea(hWnd, &mgMarInset); -} + // Make the whole window transparent. + MARGINS mgMarInset = { -1, -1, -1, -1 }; + DwmExtendFrameIntoClientArea(hWnd, &mgMarInset); + } } // namespace @@ -84,12 +95,11 @@ break; case WM_DESTROY: - if (browser) { - // Clear the user data pointer. - ui::SetWindowUserData(hwnd, NULL); - - // Destroy the browser. - browser->UIT_DestroyBrowser(); + if (browser){ + // Clear the user data pointer. + ui::SetWindowUserData(hwnd, NULL); + // Remove the browser from the list maintained by the context + _Context->RemoveBrowser(browser); } return 0; @@ -150,22 +160,23 @@ } bool CefBrowserImpl::IsWindowRenderingDisabled() { - return (window_info_.m_bWindowRenderingDisabled ? true : false); + return (window_info_.m_bWindowRenderingDisabled ? true : false); } gfx::NativeWindow CefBrowserImpl::UIT_GetMainWndHandle() { - REQUIRE_UIT(); - return window_info_.m_bWindowRenderingDisabled ? - window_info_.m_hWndParent : window_info_.m_hWnd; + REQUIRE_UIT(); + return window_info_.m_bWindowRenderingDisabled ? + window_info_.m_hWndParent : window_info_.m_hWnd; } void CefBrowserImpl::UIT_ClearMainWndHandle() { - REQUIRE_UIT(); - if (!window_info_.m_bWindowRenderingDisabled) - window_info_.m_hWnd = NULL; + REQUIRE_UIT(); + if (!window_info_.m_bWindowRenderingDisabled) + window_info_.m_hWnd = NULL; } -bool CefBrowserImpl::UIT_CreateBrowser(const CefString& url) { + +bool CefBrowserImpl::UIT_CreateBrowser(const CefString& url, bool bPopup ) { REQUIRE_UIT(); Lock(); @@ -212,6 +223,8 @@ WebPreferences prefs; BrowserToWebSettings(settings_, prefs); + if ( bPopup ) + prefs.allow_scripts_to_close_windows = true; // Create the webview host object webviewhost_.reset( @@ -247,11 +260,11 @@ } if (client_.get()) { - CefRefPtr handler = client_->GetLifeSpanHandler(); - if (handler.get()) { - // Notify the handler that we're done creating the new window - handler->OnAfterCreated(this); - } + CefRefPtr handler = client_->GetLifeSpanHandler(); + if (handler.get()) { + // Notify the handler that we're done creating the new window + handler->OnAfterCreated(this); + } } if (url.length() > 0) @@ -264,26 +277,61 @@ REQUIRE_UIT(); if (!host) return; - + +#ifdef VALVE_BUILD + UIT_GetWebView()->setFocus(enable); +#else if (enable) ::SetFocus(host->view_handle()); else if (::GetFocus() == host->view_handle()) ::SetFocus(NULL); +#endif } +/* +void CefBrowserImpl::UIT_CloseWidget() +{ + REQUIRE_UIT(); + popuphost_ = NULL; + if(handler_.get()) { + // Notify the handler that we're hiding the popup + handler_->HandleBeforeWindowClose(this); + } +}*/ + +#if defined(OS_WIN) static void WriteTextToFile(const std::string& data, - const std::wstring& file_path) { - FILE* fp; - errno_t err = _wfopen_s(&fp, file_path.c_str(), L"wt"); - if (err) - return; - fwrite(data.c_str(), 1, data.size(), fp); - fclose(fp); + const std::wstring& file_path) { + FILE* fp; + errno_t err = _wfopen_s(&fp, file_path.c_str(), L"wt"); + if (err) + return; + fwrite(data.c_str(), 1, data.size(), fp); + fclose(fp); } +#else +static void WriteTextToFile(const std::string& title, + const std::string& data, + const std::string& file_path) +{ + FILE* fp = fopen( file_path.c_str(), "wt"); + if (!fp) + return; + fwrite(title.c_str(), 1, title.size(), fp); + fwrite("\n", 1, 2, fp ); + fwrite(data.c_str(), 1, data.size(), fp); + fclose(fp); +} +#endif + + bool CefBrowserImpl::UIT_ViewDocumentString(WebKit::WebFrame *frame) { REQUIRE_UIT(); + std::string markup = frame->contentAsMarkup().utf8(); + +#if defined(OS_WIN) DWORD dwRetVal; DWORD dwBufSize = 512; TCHAR lpPathBuffer[512]; @@ -305,14 +353,35 @@ size_t len = wcslen(szTempName); wcscpy(szTempName + len - 3, L"txt"); - std::string markup = frame->contentAsMarkup().utf8(); WriteTextToFile(markup, szTempName); int errorCode = reinterpret_cast(ShellExecute(UIT_GetMainWndHandle(), L"open", szTempName, NULL, NULL, SW_SHOWNORMAL)); if (errorCode <= 32) return false; +#elif defined(OS_POSIX) + GURL gurl = frame->url(); + std::string url = gurl.possibly_invalid_spec(); + char sztmp[L_tmpnam]; + if ( tmpnam( sztmp ) ) + { + strcat( sztmp, ".txt" ); + WriteTextToFile(url, markup, sztmp); + char szopen[L_tmpnam + 16]; +#if defined(OS_MACOSX) + snprintf( szopen, sizeof( szopen ), "open -t \"%s\"", sztmp ); +#elif defined(OS_LINUX) + snprintf( szopen, sizeof( szopen ), "gnome-open \"%s\"", sztmp ); +#else +#error +#endif + return ( system( szopen ) >= 0 ); + } +#else + CHECK( 0 ); +#endif + return true; } @@ -320,6 +389,7 @@ const gfx::Size& canvas_size, WebKit::WebFrame* frame) { REQUIRE_UIT(); +#if defined(OS_WIN) printing::PrintParams params; const printing::PrintSettings &settings = print_context_.settings(); @@ -485,13 +555,14 @@ } print_context_.PageDone(); +#endif } void CefBrowserImpl::UIT_PrintPages(WebKit::WebFrame* frame) { REQUIRE_UIT(); - print_context_.Init(); - { +#if defined(OS_WIN) + print_context_.Init(); { // Make a copy of settings. printing::PrintSettings settings = print_context_.settings(); CefPrintOptions print_options; @@ -555,10 +626,12 @@ } frame->printEnd(); +#endif } int CefBrowserImpl::UIT_GetPagesCount(WebKit::WebFrame* frame) { REQUIRE_UIT(); +#if defined(OS_WIN) printing::PrintParams params; const printing::PrintSettings &settings = print_context_.settings(); @@ -584,7 +657,7 @@ params.desired_dpi)); page_count = frame->printBegin(WebSize(canvas_size)); frame->printEnd(); - +#endif return page_count; } Index: libcef/browser_request_context.cc =================================================================== --- libcef/browser_request_context.cc (revision 465) +++ libcef/browser_request_context.cc (working copy) @@ -144,8 +144,8 @@ } void BrowserRequestContext::Init( - const FilePath& cache_path, - net::HttpCache::Mode cache_mode, + const FilePath& cache_path, + net::HttpCache::Mode cache_mode, bool no_proxy) { // Create the |cache_path| directory if necessary. bool cache_path_valid = false; Index: libcef/browser_request_context.h =================================================================== --- libcef/browser_request_context.h (revision 465) +++ libcef/browser_request_context.h (working copy) @@ -21,6 +21,59 @@ class BlobStorageController; } +/*class CookieStore : public net::CookieMonster::PersistentCookieStore +{ +public: + CookieStore( const std::wstring &cookie_path ); + ~CookieStore(); + + + // Initializes the store and retrieves the existing cookies. This will be + // called only once at startup. + virtual bool Load(std::vector*); + virtual void AddCookie(const net::CookieMonster::CanonicalCookie&); + virtual void UpdateCookieAccessTime(const net::CookieMonster::CanonicalCookie& cookie); + virtual void DeleteCookie(const net::CookieMonster::CanonicalCookie& cookie); + virtual void Shutdown(); +private: + DISALLOW_COPY_AND_ASSIGN(CookieStore); + void QueueSave(); + void Load(); + void Save(); + +#pragma pack(1) + struct CookieSaveRecord + { + int64 creation_date_; + int64 last_access_date_; + int64 expiry_date_; + bool has_expires_:1; + bool secure_:1; + bool httponly_:1; + // as Var data on the end + // std::string name_; + // std::string value_; + // std::string path_; + // std::string domain_; + }; +#pragma pack() + + const char *SaveCookieRecord( const net::CookieMonster::CanonicalCookie& cookie, size_t *pOutputSize ); + size_t RestoreCookie( const char *pchData, const int cbData, CookieSaveRecord *pCookieRecord, std::string &name, std::string &value, std::string &domain, std::string &path, std::string &key, int nCookieFileVersion ); + size_t AppendString( char *pchData, const std::string &str, size_t cbCurUsed ); + size_t ReadString( const char *pchData, std::string &str ); + + typedef std::vector< net::CookieMonster::CanonicalCookie > CCookieMap; + + CCookieMap m_mapCookies; + bool m_bPostedSave; + std::wstring cookie_path_; + + char *m_pchCookieData; + size_t m_cbCookieDataAlloced; +}; +*/ + // A basic URLRequestContext that only provides an in-memory cookie store. class BrowserRequestContext : public net::URLRequestContext { public: @@ -30,7 +83,7 @@ // Use an on-disk cache at the specified location. Optionally, use the cache // in playback or record mode. - BrowserRequestContext(const FilePath& cache_path, + BrowserRequestContext( const FilePath& cache_path, net::HttpCache::Mode cache_mode, bool no_proxy); @@ -60,5 +113,9 @@ bool accept_all_cookies_; }; + +//const int k_nCookieStoreSaveTimeMS = 30 * 1000; // save every 30 secs +//const int k_nCookieFileVersion = 2; + #endif // CEF_LIBCEF_BROWSER_REQUEST_CONTEXT_H_ Index: libcef/browser_resource_loader_bridge.cc =================================================================== --- libcef/browser_resource_loader_bridge.cc (revision 465) +++ libcef/browser_resource_loader_bridge.cc (working copy) @@ -92,6 +92,30 @@ using webkit_glue::ResourceResponseInfo; +// static +bool DeserializeSecurityInfo(const std::string& state, + net::X509Certificate** cert, + int* cert_status, + int* security_bits, + int* ssl_connection_status) { + DCHECK( cert && cert_status && security_bits && ssl_connection_status); + if (state.empty()) { + // No SSL used. + *cert =NULL; + *cert_status = 0; + *security_bits = 0; // Not encrypted. + *ssl_connection_status = 0; + return false; + } + + Pickle pickle(state.data(), static_cast(state.size())); + void * iter = NULL; + *cert = net::X509Certificate::CreateFromPickle( pickle, &iter, net::X509Certificate::PICKLETYPE_CERTIFICATE_CHAIN ); + return pickle.ReadInt(&iter, cert_status) && + pickle.ReadInt(&iter, security_bits) && + pickle.ReadInt(&iter, ssl_connection_status); +} + namespace { static const char kCefUserData[] = "cef_userdata"; @@ -110,6 +134,21 @@ net::RequestPriority priority; }; + +std::string SerializeSecurityInfo( net::X509Certificate* cert, + int cert_status, + int security_bits, + int ssl_connection_status) { + Pickle pickle; + cert->Persist( &pickle ); + pickle.WriteInt(cert_status); + pickle.WriteInt(security_bits); + pickle.WriteInt(ssl_connection_status); + return std::string(static_cast(pickle.data()), pickle.size()); +} + + + // The interval for calls to RequestProxy::MaybeUpdateUploadProgress static const int kUpdateUploadProgressIntervalMsec = 100; @@ -842,7 +881,21 @@ upload_progress_timer_.Stop(); } DCHECK(request_.get()); - OnCompletedRequest(request_->status(), std::string(), base::TimeTicks()); + std::string security_info; + const net::SSLInfo& ssl_info = request_->ssl_info(); + if (ssl_info.cert != NULL) { + security_info = SerializeSecurityInfo( + ssl_info.cert, ssl_info.cert_status, ssl_info.security_bits, + ssl_info.connection_status); + } + + // only store security info for the main loaded page + if ( ( request_->load_flags() & net::LOAD_MAIN_FRAME ) && browser_.get()) + { + ((CefBrowserImpl *)browser_.get())->SetSecurityDetails( request_->url().spec().c_str(), security_info ); + } + + OnCompletedRequest(request_->status(), security_info, base::TimeTicks()); request_.reset(); // destroy on the io thread } } @@ -908,7 +961,7 @@ // Size of our async IO data buffers. Limited by the sanity check in // URLRequestJob::Read(). - static const int kDataSize = 1000000-1; + static const int kDataSize = 32*1024; // read buffer for async IO scoped_refptr buf_; @@ -1173,6 +1226,7 @@ std::string result_; }; + } // anonymous namespace //----------------------------------------------------------------------------- @@ -1180,41 +1234,39 @@ // static webkit_glue::ResourceLoaderBridge* BrowserResourceLoaderBridge::Create( const webkit_glue::ResourceLoaderBridge::RequestInfo& request_info) { - CefRefPtr browser = - _Context->GetBrowserByID(request_info.routing_id); + CefRefPtr browser = + _Context->GetBrowserByID(request_info.routing_id).get(); return new ResourceLoaderBridgeImpl(browser.get(), request_info); } -//----------------------------------------------------------------------------- - // static void BrowserResourceLoaderBridge::SetCookie(const GURL& url, - const GURL& first_party_for_cookies, - const std::string& cookie) { - // Proxy to IO thread to synchronize w/ network loading. - scoped_refptr cookie_setter = new CookieSetter(); - CefThread::PostTask(CefThread::IO, FROM_HERE, base::Bind( - &CookieSetter::Set, cookie_setter.get(), url, cookie)); + const GURL& first_party_for_cookies, + const std::string& cookie) { + // Proxy to IO thread to synchronize w/ network loading. + scoped_refptr cookie_setter = new CookieSetter(); + CefThread::PostTask(CefThread::IO, FROM_HERE, base::Bind( + &CookieSetter::Set, cookie_setter.get(), url, cookie)); } // static std::string BrowserResourceLoaderBridge::GetCookies( - const GURL& url, const GURL& first_party_for_cookies) { - // Proxy to IO thread to synchronize w/ network loading. - scoped_refptr cookie_getter = new CookieGetter(); - CefThread::PostTask(CefThread::IO, FROM_HERE, base::Bind( - &CookieGetter::Get, cookie_getter.get(), url)); + const GURL& url, const GURL& first_party_for_cookies) { + // Proxy to IO thread to synchronize w/ network loading. + scoped_refptr cookie_getter = new CookieGetter(); + CefThread::PostTask(CefThread::IO, FROM_HERE, base::Bind( + &CookieGetter::Get, cookie_getter.get(), url)); - // Blocks until the result is available. - return cookie_getter->GetResult(); + // Blocks until the result is available. + return cookie_getter->GetResult(); } // static void BrowserResourceLoaderBridge::SetAcceptAllCookies(bool accept_all_cookies) { - // Proxy to IO thread to synchronize w/ network loading. - CefThread::PostTask(CefThread::IO, FROM_HERE, base::Bind( - &BrowserRequestContext::SetAcceptAllCookies, - _Context->request_context().get(), accept_all_cookies)); + // Proxy to IO thread to synchronize w/ network loading. + CefThread::PostTask(CefThread::IO, FROM_HERE, base::Bind( + &BrowserRequestContext::SetAcceptAllCookies, + _Context->request_context().get(), accept_all_cookies)); } // static Index: libcef/browser_resource_loader_bridge.h =================================================================== --- libcef/browser_resource_loader_bridge.h (revision 465) +++ libcef/browser_resource_loader_bridge.h (working copy) @@ -25,6 +25,8 @@ const std::string& cookie); static std::string GetCookies(const GURL& url, const GURL& first_party_for_cookies); + static void DeleteCookie(const GURL& url, + const std::string& cookie ); static void SetAcceptAllCookies(bool accept_all_cookies); // Return the CefBrowser associated with the specified request. The browser Index: libcef/browser_webkit_glue.cc =================================================================== --- libcef/browser_webkit_glue.cc (revision 465) +++ libcef/browser_webkit_glue.cc (working copy) @@ -37,10 +37,14 @@ using WebKit::WebFrameImpl; +#define VALVE_BUILD // VALVE BUILD + namespace webkit_glue { void InitializeResourceBundle(const std::string& locale) { - // Load chrome.pak (on Mac) and the appropiate locale pack. +#ifndef VALVE_BUILD + + // Load chrome.pak (on Mac) and the appropiate locale pack. const std::string loaded_locale = ResourceBundle::InitSharedInstance(locale); CHECK(!loaded_locale.empty()) << "Locale could not be found for " << locale; @@ -56,6 +60,8 @@ else NOTREACHED() << "Could not load chrome.pak"; #endif + +#endif } void CleanupResourceBundle() { @@ -63,7 +69,11 @@ } string16 GetLocalizedString(int message_id) { +#ifndef VALVE_BUILD return ResourceBundle::GetSharedInstance().GetLocalizedString(message_id); +#else + return string16(); +#endif } bool IsMediaPlayerAvailable() { Index: libcef/browser_webkit_glue_gtk.cc =================================================================== --- libcef/browser_webkit_glue_gtk.cc (revision 465) +++ libcef/browser_webkit_glue_gtk.cc (working copy) @@ -10,6 +10,8 @@ namespace webkit_glue { base::StringPiece GetDataResource(int resource_id) { + return ""; // VALVE BUILD - disable loading of the data resource pak's, don't need em + /* base::StringPiece piece; // Try to load the resource from the resource pack. if (piece.empty()) @@ -18,6 +20,7 @@ DCHECK(!piece.empty()) << "Resource " << resource_id << " could not be loaded"; return piece; + */ } } // namespace webkit_glue Index: libcef/browser_webkit_glue_mac.mm =================================================================== --- libcef/browser_webkit_glue_mac.mm (revision 465) +++ libcef/browser_webkit_glue_mac.mm (working copy) @@ -40,6 +40,8 @@ } base::StringPiece GetDataResource(int resource_id) { + return ""; // VALVE BUILD - disable loading of the data resource pak's, don't need em + /* switch (resource_id) { case IDR_BROKENIMAGE: { // Use webkit's broken image icon (16x16) @@ -78,7 +80,7 @@ base::StringPiece piece = ResourceBundle::GetSharedInstance().GetRawDataResource(resource_id); DCHECK(!piece.empty()); - return piece; + return piece;*/ } void DidLoadPlugin(const std::string& filename) { Index: libcef/browser_webkit_glue_win.cc =================================================================== --- libcef/browser_webkit_glue_win.cc (revision 465) +++ libcef/browser_webkit_glue_win.cc (working copy) @@ -2,12 +2,13 @@ // 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 // found in the LICENSE file. - +#if defined(_WIN32) #include "libcef/browser_webkit_glue.h" #include #include #include +#endif #include "third_party/WebKit/Source/WebCore/config.h" MSVC_PUSH_WARNING_LEVEL(0); @@ -16,8 +17,10 @@ #undef LOG #include "base/logging.h" +#if defined(OS_WIN) #include "base/path_service.h" #include "base/win/resource_util.h" +#endif #include "skia/ext/platform_canvas.h" #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebRect.h" #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebSize.h" @@ -31,6 +34,7 @@ using WebKit::WebView; namespace webkit_glue { +#if defined(OS_WIN) base::StringPiece GetRawDataResource(HMODULE module, int resource_id) { void* data_ptr; @@ -42,6 +46,8 @@ } base::StringPiece GetDataResource(int resource_id) { + return ""; // VALVE BUILD - disable loading of the data resource pak's, don't need em + /* base::StringPiece piece; FilePath file_path; @@ -61,6 +67,7 @@ DCHECK(!piece.empty()) << "Resource " << resource_id << " could not be loaded"; return piece; + */ } bool EnsureFontLoaded(HFONT font) { @@ -73,7 +80,7 @@ size.cx = webSize.width; size.cy = webSize.height; - skia::PlatformCanvas canvas(size.cx, size.cy, true); + skia::PlatformCanvas canvas(size.cx, size.cy, true, NULL); canvas.drawARGB(255, 255, 255, 255, SkXfermode::kSrc_Mode); WebCore::PlatformContextSkia context(&canvas); WebKit::WebRect rect(0, 0, size.cx, size.cy); @@ -289,4 +296,20 @@ return ret; } +#else // OS_WIN + +string16 GetLocalizedString(int message_id) { + return string16(); +} + +void GetPlugins(bool refresh, std::vector* plugins) { + NPAPI::PluginList::Singleton()->GetPlugins(refresh, plugins); +} + +base::StringPiece NetResourceProvider(int key) { + base::StringPiece res; + return res; +} + +#endif } // namespace webkit_glue Index: libcef/browser_webview_delegate.cc =================================================================== --- libcef/browser_webview_delegate.cc (revision 465) +++ libcef/browser_webview_delegate.cc (working copy) @@ -72,6 +72,11 @@ #include "webkit/plugins/npapi/webplugin_delegate_impl.h" #include "webkit/plugins/npapi/webplugin_impl.h" +bool DeserializeSecurityInfo(const std::string& state, + net::X509Certificate** cert, + int* cert_status, + int* security_bits, + int* ssl_connection_status); #if defined(OS_WIN) #include "libcef/browser_drag_delegate_win.h" #include "libcef/web_drop_target_win.h" @@ -288,9 +293,23 @@ const WebFileChooserParams& params, WebKit::WebFileChooserCompletion* chooser_completion) { // Support file open dialog. + CefRefPtr client = browser_->GetClient(); + CefRefPtr handler = client->GetRenderHandler(); + if(handler.get()) { + if ( file_chooser_ ) + file_chooser_->didChooseFile(WebKit::WebVector()); + file_chooser_ = chooser_completion; + CefString title (params.title.utf8()); + CefString default_file(params.initialValue.utf8()); + if ( handler->OnFileOpenDialog( (CefBrowser *)browser_, params.multiSelect, + title, default_file, &file_choose_callback_ ) ) + return true; + } + +#if defined(OS_WIN) && !defined(VALVE_BUILD) std::vector file_names; - - if (!ShowFileChooser(file_names, params.multiSelect, params.title, + + if(!ShowFileChooser(file_names, params.multiSelect, params.title, webkit_glue::WebStringToFilePath(params.initialValue))) { return false; } @@ -301,7 +320,7 @@ } chooser_completion->didChooseFile(ws_file_names); - +#endif return true; } @@ -598,7 +617,7 @@ #if defined(OS_MACOSX) // Mac does not supported windowed plugins. - bool force_windowless = true; + bool force_windowless = false; #else bool force_windowless = browser_->IsWindowRenderingDisabled(); #endif @@ -684,8 +703,15 @@ WebNavigationPolicy policy) { DCHECK_NE(policy, WebKit::WebNavigationPolicyCurrentTab); std::string url = request.url().spec().data(); - CefRefPtr newBrowser = - browser_->UIT_CreatePopupWindow(url, CefPopupFeatures()); + CefRefPtr newBrowser; + // VALVE BUILD + if ( policy == WebKit::WebNavigationPolicyNewBackgroundTab || policy == WebKit::WebNavigationPolicyNewForegroundTab ) + { + bool bForeground = (policy == WebKit::WebNavigationPolicyNewForegroundTab) ? true : false; + newBrowser = browser_->UIT_CreateNewTab(url, CefPopupFeatures(), bForeground ); + } + else + newBrowser = browser_->UIT_CreatePopupWindow(url, CefPopupFeatures()); if (newBrowser.get() && !url.empty()) newBrowser->GetMainFrame()->LoadURL(url); } @@ -726,10 +752,15 @@ else navType = (cef_handler_navtype_t)type; + // VALVE BUILD + bool bIsNewTabRequest = false; + if ( default_policy == WebKit::WebNavigationPolicyNewBackgroundTab || default_policy == WebKit::WebNavigationPolicyNewForegroundTab ) + bIsNewTabRequest = true; + // Notify the handler of a browse request bool handled = handler->OnBeforeBrowse(browser_, browser_->UIT_GetCefFrame(frame), req, navType, - is_redirect); + is_redirect, bIsNewTabRequest); if (handled) return WebKit::WebNavigationPolicyIgnore; } @@ -782,14 +813,34 @@ WebFrame* frame, const WebURLError& error) { // error codes are defined in net\base\net_error_list.h + std::string error_text; + CefString errorStr; + // Don't display an error page if this is simply a cancelled load. Aside // from being dumb, WebCore doesn't expect it and it will cause a crash. if (error.reason == net::ERR_ABORTED) - return; + { + // VALVE BUILD + CefRefPtr client = browser_->GetClient(); + if (client.get()) { + CefRefPtr handler = client->GetLoadHandler(); + if (handler.get()) { + // give the handler an opportunity to generate a custom error message + CefString errorStr; + handler->OnLoadError(browser_, + browser_->UIT_GetCefFrame(frame), + static_cast(error.reason), + std::string(error.unreachableURL.spec().data()), errorStr ); + } + } + return; + // VALVE BUILD + } const WebDataSource* failed_ds = frame->provisionalDataSource(); BrowserExtraData* extra_data = static_cast(failed_ds->extraData()); + bool replace = extra_data && extra_data->pending_page_id != -1; if (extra_data && !extra_data->request_committed) { // Set the pending extra_data for our error page as the same pending_page_id @@ -797,8 +848,6 @@ set_pending_extra_data(new BrowserExtraData(extra_data->pending_page_id)); } - std::string error_text; - CefString errorStr; bool handled = false; @@ -825,8 +874,7 @@ frame->enableViewSourceMode(false); frame->loadHTMLString( - error_text, GURL("cef-error:"), error.unreachableURL, false); - + error_text, GURL( failed_ds->request().url().spec().data() ), error.unreachableURL, replace); // In case loadHTMLString failed before DidCreateDataSource was called. set_pending_extra_data(NULL); } @@ -842,7 +890,7 @@ UpdateForCommittedLoad(frame, is_new_navigation); CefRefPtr client = browser_->GetClient(); - if (client.get()) { + if ( is_new_navigation && client.get()) { // VALVE BUILD - only fire this on new navigation CefRefPtr handler = client->GetLoadHandler(); if (handler.get()) { // Notify the handler that loading has started. @@ -917,11 +965,69 @@ void BrowserWebViewDelegate::didFailLoad( WebFrame* frame, const WebURLError& error) { - LocationChangeDone(frame); + CefRefPtr req(CefRequest::CreateRequest()); // VALVE BUILD + LocationChangeDone(frame, req); } void BrowserWebViewDelegate::didFinishLoad(WebFrame* frame) { - LocationChangeDone(frame); + + const WebDataSource* ds = frame->dataSource(); + + CefRefPtr req(CefRequest::CreateRequest()); + + GURL request_url = ds->response().url(); + + // VALVE BUILD + CefSecurityDetailsImpl *securityData = new CefSecurityDetailsImpl(); + + std::string security_info; + browser_->GetSecurityDetails( request_url.spec().c_str(), security_info ); + net::X509Certificate *cert; + int cert_status, security_bits, ssl_connection_status; + if ( DeserializeSecurityInfo( security_info, &cert, &cert_status, &security_bits, &ssl_connection_status) ) + { + std::string org; + if (!cert->subject().organization_names.empty()) + org = cert->subject().organization_names[0]; + if (org.empty()) + org = cert->subject().GetDisplayName(); + + if ( !cert->subject().country_name.empty() ) + { + org += " ["; + org += cert->subject().country_name; + org += "]"; + } + + std::string issuerName; + if (!cert->issuer().organization_names.empty()) + issuerName = cert->issuer().organization_names[0]; + if (issuerName.empty()) + issuerName = cert->issuer().GetDisplayName(); + + securityData->SetParameters( true, net::IsCertStatusError(cert_status), org.c_str(), issuerName.c_str(), cert->valid_expiry().ToTimeT(), security_bits, ( cert_status & net::CERT_STATUS_IS_EV ) > 0 ? true : false ); + } + + req->SetSecurityDetails( securityData ); + // VALVE BUILD + + req->SetURL( request_url.spec() ); + req->SetMethod( + string16(ds->request().httpMethod()) ); + + const WebKit::WebHTTPBody& httpBody = ds->request().httpBody(); + if(!httpBody.isNull()) { + CefRefPtr postdata(CefPostData::CreatePostData()); + static_cast(postdata.get())->Set(httpBody); + req->SetPostData(postdata); + } + + CefRequest::HeaderMap map; + CefRequestImpl::GetHeaderMap(ds->response(), map); + if(map.size() > 0) + static_cast(req.get())->SetHeaderMap(map); + + LocationChangeDone(frame, req); } void BrowserWebViewDelegate::didNavigateWithinPage( @@ -994,7 +1100,10 @@ #else select_trailing_whitespace_enabled_(false), #endif - block_redirects_(false) { + block_redirects_(false), + file_chooser_( NULL ), + ALLOW_THIS_IN_INITIALIZER_LIST( file_choose_callback_( this ) ) +{ } BrowserWebViewDelegate::~BrowserWebViewDelegate() { @@ -1077,7 +1186,7 @@ } } -void BrowserWebViewDelegate::LocationChangeDone(WebFrame* frame) { +void BrowserWebViewDelegate::LocationChangeDone(WebFrame* frame, CefRefPtr req) { CefRefPtr client = browser_->GetClient(); if (!client.get()) return; @@ -1099,7 +1208,7 @@ // Notify the handler that loading has ended. int httpStatusCode = frame->dataSource()->response().httpStatusCode(); handler->OnLoadEnd(browser_, browser_->UIT_GetCefFrame(frame), - httpStatusCode); + httpStatusCode, req); } } Index: libcef/browser_webview_delegate.h =================================================================== --- libcef/browser_webview_delegate.h (revision 465) +++ libcef/browser_webview_delegate.h (working copy) @@ -16,6 +16,7 @@ #include #include "libcef/browser_navigation_controller.h" +//#include "include/cef_types.h" #include "base/basictypes.h" #include "base/compiler_specific.h" @@ -32,6 +33,7 @@ #include "webkit/glue/webcursor.h" #include "webkit/plugins/npapi/webplugin_page_delegate.h" + #if defined(TOOLKIT_USES_GTK) #include // NOLINT(build/include_order) #endif @@ -49,8 +51,18 @@ class CefBrowserImpl; class GURL; class WebWidgetHost; -class FilePath; +class BrowserWebViewDelegate; +class CefFileChooseCallback : public cef_web_file_chooser_callback +{ +public: + CefFileChooseCallback( BrowserWebViewDelegate *parent ) { parent_ = parent; } + ~CefFileChooseCallback() {} + virtual void OnFileChoose(const std::vector& file_names); +private: + BrowserWebViewDelegate *parent_; +}; + class BrowserWebViewDelegate : public WebKit::WebViewClient, public WebKit::WebFrameClient, public WebKit::WebPermissionClient, @@ -279,7 +291,12 @@ bool OnKeyboardEvent(const WebKit::WebKeyboardEvent& event, bool isAfterJavaScript); - protected: + // VALVE BUILD + WebKit::WebFileChooserCompletion *file_chooser() { return file_chooser_; } + void reset_file_chooser() { file_chooser_ = NULL; } + // VALVE BUILD + +protected: // Default handling of JavaScript messages. void ShowJavaScriptAlert(WebKit::WebFrame* webframe, const CefString& message); @@ -294,7 +311,7 @@ bool ShowFileChooser(std::vector& file_names, const bool multi_select, const WebKit::WebString& title, - const FilePath& default_file); + const FilePath& default_file, WebKit::WebFileChooserCompletion* file_chooser ); // Called to show status messages. void ShowStatus(const WebKit::WebString& text, cef_handler_statustype_t type); @@ -302,7 +319,7 @@ // 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 // test. - void LocationChangeDone(WebKit::WebFrame*); + void LocationChangeDone(WebKit::WebFrame*, CefRefPtr req); WebWidgetHost* GetWidgetHost(); @@ -371,6 +388,11 @@ std::string edit_command_name_; std::string edit_command_value_; + // pointer to any pending file open callback + WebKit::WebFileChooserCompletion *file_chooser_; + + CefFileChooseCallback file_choose_callback_; + DISALLOW_COPY_AND_ASSIGN(BrowserWebViewDelegate); }; Index: libcef/browser_webview_delegate_gtk.cc =================================================================== --- libcef/browser_webview_delegate_gtk.cc (revision 465) +++ libcef/browser_webview_delegate_gtk.cc (working copy) @@ -28,6 +28,7 @@ #include "webkit/plugins/npapi/plugin_list.h" #include "webkit/plugins/npapi/webplugin.h" #include "webkit/plugins/npapi/webplugin_delegate_impl.h" +#include "base/utf_string_conversions.h" // VALVE BUILD #include // NOLINT(build/include_order) #include // NOLINT(build/include_order) @@ -375,11 +376,46 @@ return false; } +#ifdef VALVE_BUILD +void CefFileChooseCallback::OnFileChoose(const std::vector& file_names) +{ + if ( parent_->file_chooser() ) { + std::vector vecPaths; + for (std::vector::const_iterator filename = + file_names.begin(); filename != file_names.end(); ++filename) { + vecPaths.push_back( WebKit::WebString::fromUTF8( WideToUTF8( *filename ) ) ); + } + parent_->file_chooser()->didChooseFile( vecPaths ); + parent_->reset_file_chooser(); + } +} + +bool BrowserWebViewDelegate::ShowFileChooser(std::vector& file_names, + const bool multi_select, + const WebKit::WebString& title, + const FilePath& default_file, + WebKit::WebFileChooserCompletion* file_chooser) { + CefRefPtr client = browser_->GetClient(); + CefRefPtr handler; + if (client.get()) + { + handler = client->GetRenderHandler(); + file_chooser_ = file_chooser; + if ( handler->OnFileOpenDialog( browser_, multi_select, string16(title), default_file.AsUTF8Unsafe(), &file_choose_callback_ ) ) + return false; + } + + return false; +} + +#else // Called to show the file chooser dialog. bool BrowserWebViewDelegate::ShowFileChooser(std::vector& file_names, const bool multi_select, const WebKit::WebString& title, - const FilePath& default_file) { + const FilePath& default_file, + WebKit::WebFileChooserCompletion* file_chooser ) { NOTIMPLEMENTED(); return false; } +#endif Index: libcef/browser_webview_delegate_linux.cc =================================================================== --- libcef/browser_webview_delegate_linux.cc (revision 0) +++ libcef/browser_webview_delegate_linux.cc (working copy) @@ -0,0 +1 @@ +browser_webview_delegate_win.cc \ No newline at end of file Index: libcef/browser_webview_delegate_mac.mm =================================================================== --- libcef/browser_webview_delegate_mac.mm (revision 465) +++ libcef/browser_webview_delegate_mac.mm (working copy) @@ -27,6 +27,7 @@ #include "webkit/plugins/npapi/plugin_list.h" #include "webkit/plugins/npapi/webplugin_delegate_impl.h" #include "webkit/glue/webmenurunner_mac.h" +#include "base/utf_string_conversions.h" // VALVE BUILD using webkit::npapi::WebPluginDelegateImpl; using WebKit::WebContextMenuData; @@ -194,9 +195,44 @@ // WebWidgetClient ------------------------------------------------------------ void BrowserWebViewDelegate::show(WebNavigationPolicy policy) { + if (this == browser_->UIT_GetPopupDelegate()) { + if (browser_->IsWindowRenderingDisabled()) { + // Notify the handler of popup visibility change. + CefRefPtr client = browser_->GetClient(); + if (client.get()) { + CefRefPtr handler = client->GetRenderHandler(); + if (handler.get()) + handler->OnPopupShow(browser_, true); + } + } + } } void BrowserWebViewDelegate::didChangeCursor(const WebCursorInfo& cursor_info) { + WebWidgetHost* host = GetWidgetHost(); + if (host) { + current_cursor_.InitFromCursorInfo(cursor_info); + CefRefPtr client = browser_->GetClient(); + if (client.get()) { + CefRefPtr handler = client->GetRenderHandler(); + if (handler.get()) + { + const void *pCustomPixels = NULL; + int wide = 0, tall = 0, xhot = 0, yhot = 0; + if ( cursor_info.type == WebCursorInfo::TypeCustom ) + { + pCustomPixels = cursor_info.customImage.getSkBitmap().getPixels(); + wide = cursor_info.customImage.size().width; + tall = cursor_info.customImage.size().height; + xhot = cursor_info.hotSpot.x; + yhot = cursor_info.hotSpot.y; + } + if ( handler->OnSetCursor( browser_, (const CefRenderHandler::CursorType)cursor_info.type, pCustomPixels, wide, tall, xhot, yhot ) ) + return; + } + } + } + NSCursor* ns_cursor = WebCursor(cursor_info).GetCursor(); [ns_cursor set]; } @@ -213,6 +249,21 @@ void BrowserWebViewDelegate::setWindowRect(const WebRect& rect) { if (this == browser_->UIT_GetWebViewDelegate()) { // TODO(port): Set the window rectangle. + } else if (this == browser_->UIT_GetPopupDelegate()) { + if (browser_->IsWindowRenderingDisabled()) { + browser_->set_popup_rect(rect); + browser_->UIT_GetPopupHost()->SetSize(rect.width, rect.height); + + // Notify the handler of popup size change. + CefRefPtr client = browser_->GetClient(); + if (client.get()) { + CefRefPtr handler = client->GetRenderHandler(); + if (handler.get()) { + handler->OnPopupSize(browser_, + CefRect(rect.x, rect.y, rect.width, rect.height)); + } + } + } } } @@ -332,15 +383,34 @@ void BrowserWebViewDelegate::CreatedPluginWindow( gfx::PluginWindowHandle handle) { + + if (browser_->IsWindowRenderingDisabled()) { + + WebViewHost* host = browser_->UIT_GetWebViewHost(); + if (host) + host->AddWindowedPlugin(handle); + } } void BrowserWebViewDelegate::WillDestroyPluginWindow( gfx::PluginWindowHandle handle) { + + if (browser_->IsWindowRenderingDisabled()) { + WebViewHost* host = browser_->UIT_GetWebViewHost(); + if (host) + host->RemoveWindowedPlugin(handle); + } } void BrowserWebViewDelegate::DidMovePlugin( const webkit::npapi::WebPluginGeometry& move) { - // TODO(port): add me once plugins work. + + if (browser_->IsWindowRenderingDisabled()) { + WebViewHost* host = browser_->UIT_GetWebViewHost(); + if (host) { + host->MoveWindowedPlugin(move); + } + } } // Protected methods ---------------------------------------------------------- @@ -370,6 +440,40 @@ return false; } +// VALVE BUILD +#ifdef VALVE_BUILD +void CefFileChooseCallback::OnFileChoose(const std::vector& file_names) +{ + if ( parent_->file_chooser() ) { + std::vector vecPaths; + for (std::vector::const_iterator filename = + file_names.begin(); filename != file_names.end(); ++filename) { + vecPaths.push_back( WebKit::WebString::fromUTF8( WideToUTF8( *filename ) ) ); + } + parent_->file_chooser()->didChooseFile( vecPaths ); + parent_->reset_file_chooser(); + } +} + +bool BrowserWebViewDelegate::ShowFileChooser(std::vector& file_names, + const bool multi_select, + const WebKit::WebString& title, + const FilePath& default_file, + WebKit::WebFileChooserCompletion* file_chooser) { + CefRefPtr client = browser_->GetClient(); + CefRefPtr handler; + if (client.get()) + { + handler = client->GetRenderHandler(); + file_chooser_ = file_chooser; + if ( handler->OnFileOpenDialog( browser_, multi_select, string16(title), default_file.AsUTF8Unsafe(), &file_choose_callback_ ) ) + return false; + } + + return false; +} +#else // VALVE BUILD + // Called to show the file chooser dialog. bool BrowserWebViewDelegate::ShowFileChooser(std::vector& file_names, const bool multi_select, @@ -414,3 +518,4 @@ return true; } +#endif // VALVE BUILD Index: libcef/browser_webview_delegate_win.cc =================================================================== --- libcef/browser_webview_delegate_win.cc (revision 465) +++ libcef/browser_webview_delegate_win.cc (working copy) @@ -42,7 +42,6 @@ #include "webkit/plugins/npapi/webplugin.h" #include "webkit/plugins/npapi/webplugin_delegate_impl.h" -using webkit::npapi::WebPluginDelegateImpl; using WebKit::WebContextMenuData; using WebKit::WebCursorInfo; using WebKit::WebDragData; @@ -142,7 +141,44 @@ void BrowserWebViewDelegate::didChangeCursor(const WebCursorInfo& cursor_info) { if (WebWidgetHost* host = GetWidgetHost()) { - current_cursor_.InitFromCursorInfo(cursor_info); + current_cursor_.InitFromCursorInfo(cursor_info); + CefRefPtr client = browser_->GetClient(); + if (client.get()) { + CefRefPtr handler = client->GetRenderHandler(); + if (handler.get()) + { + const void *pCustomPixels = NULL; + int wide = 0, tall = 0, xhot = 0, yhot = 0; + if ( cursor_info.type == TypeCustom ) + { + #if defined( OS_MACOSX ) + pCustomPixels = cursor_info.customImage.getCGImageRef(); + #else + pCustomPixels = cursor_info.customImage.getSkBitmap().getPixels(); + #endif + wide = cursor_info.customImage.size().width; + tall = cursor_info.customImage.size().height; + xhot = cursor_info.hotSpot.x; + yhot = cursor_info.hotSpot.y; + } + if ( handler->OnSetCursor( browser_, (const CefRenderHandler::CursorType)cursor_info.type, pCustomPixels, wide, tall, xhot, yhot ) ) + return; + } + } + + const std::wstring &str = _Context->GetResourceDllName(); + const wchar_t *pchDllName = str.c_str(); + if ( str.length() <= 0 ) + pchDllName = NULL; + +#if defined(OS_WIN) + HINSTANCE mod_handle = GetModuleHandle( pchDllName); + host->SetCursor(current_cursor_.GetCursor(mod_handle)); +#else + CHECK(0); + (void)host; + //host->SetCursor(current_cursor_.GetCursor(NULL)); +#endif HMODULE hModule = ::GetModuleHandle(L"libcef.dll"); if (!hModule) hModule = ::GetModuleHandle(NULL); @@ -209,12 +245,14 @@ } WebRect BrowserWebViewDelegate::rootWindowRect() { +#ifndef VALVE_BUILD if (WebWidgetHost* host = GetWidgetHost()) { RECT rect; HWND root_window = ::GetAncestor(host->view_handle(), GA_ROOT); ::GetWindowRect(root_window, &rect); return gfx::Rect(rect); } +#endif return WebRect(); } @@ -327,10 +365,10 @@ // Parent the plugin container to the main window handle provided by the // user. hwnd = browser_->UIT_GetMainWndHandle(); - DCHECK(hwnd != NULL); + //DCHECK(hwnd != NULL); } - return WebPluginDelegateImpl::Create(file_path, mime_type, hwnd); + return webkit::npapi::WebPluginDelegateImpl::Create(file_path, mime_type, hwnd); } void BrowserWebViewDelegate::CreatedPluginWindow( @@ -377,6 +415,7 @@ void BrowserWebViewDelegate::DidMovePlugin( const webkit::npapi::WebPluginGeometry& move) { +#if defined(OS_WIN) UINT flags = 0; if (move.rects_valid) { @@ -405,6 +444,7 @@ move.window_rect.width(), move.window_rect.height(), flags); +#endif if (browser_->IsWindowRenderingDisabled()) { WebViewHost* host = browser_->UIT_GetWebViewHost(); @@ -546,12 +586,15 @@ bool BrowserWebViewDelegate::ShowJavaScriptConfirm(WebFrame* webframe, const CefString& message) { +#ifndef VALVE_BUILD // TODO(cef): Think about what we should be showing as the prompt caption std::wstring messageStr = message; std::wstring titleStr = browser_->UIT_GetTitle(); int rv = MessageBox(browser_->UIT_GetMainWndHandle(), messageStr.c_str(), titleStr.c_str(), MB_YESNO | MB_ICONQUESTION); return (rv == IDYES); +#endif + return true; } bool BrowserWebViewDelegate::ShowJavaScriptPrompt(WebFrame* webframe, @@ -562,6 +605,39 @@ return false; } +#ifdef VALVE_BUILD +void CefFileChooseCallback::OnFileChoose(const std::vector& file_names) +{ + if ( parent_->file_chooser() ) { + std::vector vecPaths; + for (std::vector::const_iterator filename = + file_names.begin(); filename != file_names.end(); ++filename) { + vecPaths.push_back( *filename ); + } + parent_->file_chooser()->didChooseFile( vecPaths ); + parent_->reset_file_chooser(); + } +} + +bool BrowserWebViewDelegate::ShowFileChooser(std::vector& file_names, + const bool multi_select, + const WebKit::WebString& title, + const FilePath& default_file, + WebKit::WebFileChooserCompletion* file_chooser) { + CefRefPtr client = browser_->GetClient(); + CefRefPtr handler; + if (client.get()) + { + handler = client->GetRenderHandler(); + file_chooser_ = file_chooser; + if ( handler->OnFileOpenDialog( browser_, multi_select, string16(title), default_file.AsUTF8Unsafe(), &file_choose_callback_ ) ) + return false; + } + + return false; +} + +#else namespace { // from chrome/browser/views/shell_dialogs_win.cc @@ -647,7 +723,6 @@ } } // namespace - bool BrowserWebViewDelegate::ShowFileChooser(std::vector& file_names, const bool multi_select, const WebKit::WebString& title, @@ -668,3 +743,4 @@ return result; } +#endif Index: libcef/browser_webview_mac.mm =================================================================== --- libcef/browser_webview_mac.mm (revision 465) +++ libcef/browser_webview_mac.mm (working copy) @@ -70,7 +70,8 @@ update_rgn.op(min_x, min_y, max_x, max_y, SkRegion::kUnion_Op); } - browser_->UIT_GetWebViewHost()->Paint(update_rgn); + // VALVE BUILD - removed unused param to paint + browser_->UIT_GetWebViewHost()->Paint(); } } Index: libcef/browser_zoom_map.cc =================================================================== --- libcef/browser_zoom_map.cc (revision 465) +++ libcef/browser_zoom_map.cc (working copy) @@ -2,34 +2,37 @@ // reserved. Use of this source code is governed by a BSD-style license that can // be found in the LICENSE file. -#include "libcef/browser_zoom_map.h" -#include "libcef/cef_thread.h" +#include "browser_zoom_map.h" +#include "cef_thread.h" -ZoomMap* ZoomMap::GetInstance() { - return Singleton::get(); +ZoomMap* ZoomMap::GetInstance() +{ + return Singleton::get(); } -void ZoomMap::set(const GURL& url, double zoomLevel) { - REQUIRE_UIT(); - - if (zoomLevel == 0.) { - // Remove the entry for this host. - Map::iterator iter = map_.find(url.host()); - if (iter != map_.end()) - map_.erase(iter); - } else { - // Update the entry for this host. - map_[url.host()] = zoomLevel; - } +void ZoomMap::set(const GURL& url, double zoomLevel) +{ + REQUIRE_UIT(); + + if (zoomLevel == 0.) { + // Remove the entry for this host. + Map::iterator iter = map_.find(url.host()); + if (iter != map_.end()) + map_.erase(iter); + } else { + // Update the entry for this host. + map_[url.host()] = zoomLevel; + } } -bool ZoomMap::get(const GURL& url, double& zoomLevel) { - REQUIRE_UIT(); - - Map::const_iterator iter = map_.find(url.host()); - if (iter == map_.end()) - return false; - - zoomLevel = iter->second; - return true; +bool ZoomMap::get(const GURL& url, double& zoomLevel) +{ + REQUIRE_UIT(); + + Map::const_iterator iter = map_.find(url.host()); + if (iter == map_.end()) + return false; + + zoomLevel = iter->second; + return true; } Index: libcef/browser_zoom_map.h =================================================================== --- libcef/browser_zoom_map.h (revision 465) +++ libcef/browser_zoom_map.h (working copy) @@ -2,42 +2,41 @@ // reserved. Use of this source code is governed by a BSD-style license that can // be found in the LICENSE file. -#ifndef CEF_LIBCEF_BROWSER_ZOOM_MAP_H_ -#define CEF_LIBCEF_BROWSER_ZOOM_MAP_H_ -#pragma once +#ifndef _BROWSER_ZOOM_MAP_H +#define _BROWSER_ZOOM_MAP_H +#include "base/memory/singleton.h" +#include "googleurl/src/gurl.h" + #include #include -#include "include/internal/cef_string.h" -#include "base/memory/singleton.h" -#include "googleurl/src/gurl.h" - // Maps the host/domain of a URL to a zoom value. // NOTE: This class is not thread-safe. It is assumed that the methods will be // called from the UI thread. -class ZoomMap { - public: - // Returns the static ZoomMap instance. - static ZoomMap* GetInstance(); - - // Store |zoomLevel| with key |url|. - void set(const GURL& url, double zoomLevel); - - // Returns true if there is a |zoomLevel| keyed with |url|, false otherwise. - // |zoomLevel| is the "out" variable. - bool get(const GURL& url, double& zoomLevel); - - private: - typedef std::map Map; - Map map_; - - friend struct DefaultSingletonTraits; - - ZoomMap() {} - virtual ~ZoomMap() {} - - DISALLOW_COPY_AND_ASSIGN(ZoomMap); +class ZoomMap +{ +public: + // Returns the static ZoomMap instance. + static ZoomMap* GetInstance(); + + // Store |zoomLevel| with key |url|. + void set(const GURL& url, double zoomLevel); + + // Returns true if there is a |zoomLevel| keyed with |url|, false otherwise. + // |zoomLevel| is the "out" variable. + bool get(const GURL& url, double& zoomLevel); + +private: + typedef std::map Map; + Map map_; + + friend struct DefaultSingletonTraits; + + ZoomMap() {} + virtual ~ZoomMap() {} + + DISALLOW_COPY_AND_ASSIGN(ZoomMap); }; -#endif // CEF_LIBCEF_BROWSER_ZOOM_MAP_H_ +#endif // _BROWSER_ZOOM_MAP_H Index: libcef/cef_context.cc =================================================================== --- libcef/cef_context.cc (revision 465) +++ libcef/cef_context.cc (working copy) @@ -10,6 +10,7 @@ #include "base/bind.h" #include "base/file_util.h" #include "base/synchronization/waitable_event.h" +#include "net/disk_cache/disk_cache.h" // VALVE BUILD #if defined(OS_MACOSX) || defined(OS_WIN) #include "crypto/nss_util.h" @@ -40,7 +41,7 @@ } // namespace -bool CefInitialize(const CefSettings& settings, CefRefPtr application) { +bool CefInitialize( const CefSettings& settings, CefRefPtr application, const CefString pchResourceDLL ) { // Return true if the global context already exists. if (_Context.get()) return true; @@ -54,7 +55,7 @@ _Context = new CefContext(); // Initialize the global context. - return _Context->Initialize(settings, application); + return _Context->Initialize(settings, application, pchResourceDLL ); } void CefShutdown() { @@ -93,6 +94,55 @@ _Context->process()->DoMessageLoopIteration(); } +void CefClearHTMLCache() +{ + if(!_Context.get()) + return; + + _Context->ClearHTMLCache(); +} +/* +bool CefBSupportsMimeType( const char *pchMimeType ) +{ + std::vector plugins; + NPAPI::PluginList::Singleton()->GetPlugins( false, &plugins ); + + for(size_t i = 0; i < plugins.size(); ++i) + { + for ( size_t iMime = 0; iMime < plugins[i].mime_types.size(); iMime++ ) + { + if ( plugins[i].mime_types[iMime].mime_type == pchMimeType ) + return true; + } + } + return false; +} + +void CefRemoveBrowser( CefRefPtr browser ) +{ + // Verify that the context is already initialized + if(!_Context.get()) + return; + + CefRefPtr handler = browser->GetHandler(); + if(handler.get()) { + // Notify the handler that the window is about to be closed + handler->HandleBeforeWindowClose(browser); + } + CefBrowserImpl *browserimpl = static_cast(browser.get()); + browserimpl->GetWebViewDelegate()->RevokeDragDrop(); + + WebKit::WebFrame *webframe = browserimpl->GetWebView()->mainFrame(); + webframe->collectGarbage(); + webframe->collectGarbage(); + + // Clean up anything associated with the WebViewHost widget. + browserimpl->GetWebViewHost()->webwidget()->close(); + + _Context->RemoveBrowser( browserimpl ); +} +*/ + void CefRunMessageLoop() { // Verify that the context is in a valid state. if (!CONTEXT_STATE_VALID()) { @@ -132,6 +182,7 @@ : initialized_(false), shutting_down_(false), next_browser_id_(kNextBrowserIdReset), + clear_html_cache_completed_( false, false ), // VALVE BUILD current_webviewhost_(NULL) { } @@ -141,9 +192,10 @@ } bool CefContext::Initialize(const CefSettings& settings, - CefRefPtr application) { + CefRefPtr application, const CefString pchResourceDll ) { settings_ = settings; application_ = application; + resource_dll_ = pchResourceDll; cache_path_ = FilePath(CefString(&settings.cache_path)); @@ -254,6 +306,40 @@ return deleted; } +// VALVE BUILD +void CefContext::ClearCacheOnIOThread() +{ + net::HttpCache* http_cache = request_context_->http_transaction_factory()->GetCache(); + if (!http_cache || !http_cache->GetCurrentBackend()) + return; + + // The cache can be empty, for example on startup, in which case |cache| will + // be null and we don't need to do anything. + // HACK - DoomAllEntries doesn't currently (14-jul-2010) post to the callback + if (http_cache && http_cache->GetCurrentBackend()) { + net::CompletionCallback callback = + base::Bind(&CefContext::DoClearCache, make_scoped_refptr(this)); + http_cache->GetCurrentBackend()->DoomAllEntries( callback ); + } + else + clear_html_cache_completed_.Signal(); +} + +void CefContext::DoClearCache( int rv ) +{ + clear_html_cache_completed_.Signal(); +} + +void CefContext::ClearHTMLCache() +{ + CefThread::PostTask( CefThread::IO, FROM_HERE,NewRunnableMethod( + this,&CefContext::ClearCacheOnIOThread)); + + clear_html_cache_completed_.Wait(); +} +// VALVE BUILD + + CefRefPtr CefContext::GetBrowserByID(int id) { AutoLock lock_scope(this); @@ -306,3 +392,358 @@ browser_shutdown_event->Signal(); } } +/*CookieStore::CookieStore( const std::wstring &cookie_path ) +{ + m_pchCookieData = NULL; + m_cbCookieDataAlloced = 0; + cookie_path_ = cookie_path; + m_bPostedSave = false; + if ( !cookie_path_.empty() ) + { +#if defined(OS_WIN) + if ( cookie_path_[ cookie_path_.length() - 1 ] != L'\\' ) + cookie_path_.append( L"\\" ); +#else + if ( cookie_path_[ cookie_path_.length() - 1 ] != L'/' ) + cookie_path_.append( L"/" ); +#endif + cookie_path_.append( L"wcf.db" ); // filename to save into + } +} + + +CookieStore::~CookieStore() +{ + Shutdown(); + if ( m_pchCookieData ) + free( m_pchCookieData ); + m_pchCookieData = NULL; +} + +void CookieStore::Shutdown() +{ + if ( m_bPostedSave ) + Save(); +} + + +bool CookieStore::Load(std::vector*pVec) +{ + m_mapCookies.clear(); + Load(); + CCookieMap::iterator it = m_mapCookies.begin(); + while ( it != m_mapCookies.end() ) + { + pVec->push_back(new net::CookieMonster::CanonicalCookie( it->Name(), it->Value(), it->Domain(), + it->Path(), it->IsSecure(), it->IsHttpOnly(), it->CreationDate(), it->LastAccessDate(), + it->DoesExpire(), it->ExpiryDate() ) ); + it++; + } + return true; +} + + +void CookieStore::QueueSave() +{ + if ( !m_bPostedSave ) + { + m_bPostedSave = true; + CefThread::PostDelayedTask(CefThread::UI, FROM_HERE, + NewRunnableMethod( this, &CookieStore::Save), k_nCookieStoreSaveTimeMS); + } +} + + +void CookieStore::AddCookie( const net::CookieMonster::CanonicalCookie& cookie) +{ + m_mapCookies.push_back( cookie ); + QueueSave(); +} + + +void CookieStore::UpdateCookieAccessTime(const net::CookieMonster::CanonicalCookie& cookie) +{ + CCookieMap::iterator it = m_mapCookies.begin(); + while ( it != m_mapCookies.end() ) + { + if ( cookie.CreationDate() == it->CreationDate() && cookie.IsEquivalent( *it ) ) + { + *it = cookie; + } + it++; + } + + QueueSave(); +} + + +void CookieStore::DeleteCookie(const net::CookieMonster::CanonicalCookie& cookie) +{ + CCookieMap::iterator it = m_mapCookies.begin(); + while ( it != m_mapCookies.end() ) + { + if ( cookie.CreationDate() == it->CreationDate() && cookie.IsEquivalent( *it ) ) + { + m_mapCookies.erase( it ); + break; + } + it++; + } + + QueueSave(); +} + + +void CookieStore::Save() +{ + m_bPostedSave = false; + if ( cookie_path_.empty() ) + return; + // save it to disk + FILE *fp = fopen( WideToUTF8(cookie_path_).c_str(), "wb" ); + if ( fp ) + { + fwrite( &k_nCookieFileVersion, sizeof(k_nCookieFileVersion), 1, fp ); + CCookieMap::iterator it = m_mapCookies.begin(); + while ( it != m_mapCookies.end() ) + { + if ( !it->IsExpired( base::Time::Now() ) ) + { + size_t dataLen = 0; + const char *pchData = SaveCookieRecord( *it, &dataLen ); + if ( dataLen > 0 ) + { + size_t dataCount = fwrite( pchData, dataLen, 1, fp ); + if ( dataCount != 1 ) + break; // corrupt record, we are done + } + // if we fail to serialize a particular cookie just ignore it and save the rest + } + + it++; + } + + fclose( fp ); + } +} + + +void CookieStore::Load() +{ + if ( cookie_path_.empty() ) + return; // in memory only + // load it from disk + FILE *fp = fopen( WideToUTF8(cookie_path_).c_str(), "rb" ); + if ( fp ) + { + bool bOldCookieFile = false; + struct stat stat_; + int ret = fstat( _fileno( fp ), &stat_ ); + if ( ret == 0 ) + { + int fileVersion = 0; + if ( fread( &fileVersion, sizeof(k_nCookieFileVersion), 1, fp ) != 1 ) + { + fclose( fp ); + return; + } + + if ( fileVersion != k_nCookieFileVersion && fileVersion != 1 ) + { + fclose( fp ); + return; + } + if ( fileVersion < k_nCookieFileVersion ) + bOldCookieFile = true; + + m_cbCookieDataAlloced = stat_.st_size - sizeof(k_nCookieFileVersion); + m_pchCookieData = (char *)malloc( m_cbCookieDataAlloced ); + int readCount = fread( m_pchCookieData, m_cbCookieDataAlloced, 1, fp ); + if ( readCount != 1 ) + { + fclose( fp ); + return; + } + + const char *pchData = m_pchCookieData; + const char *pchDataEnd = m_pchCookieData + m_cbCookieDataAlloced; + while ( pchData < pchDataEnd ) + { + CookieSaveRecord cookieSave; + std::string name, value, path, key, domain = ""; + int readLen = RestoreCookie( pchData, pchDataEnd - pchData, &cookieSave, name, value, domain, path, key, fileVersion ); + if ( readLen == 0 ) + break; + + pchData += readLen; + + + net::CookieMonster::CanonicalCookie cookie( + name, value, domain, path, + cookieSave.secure_, cookieSave.httponly_, + base::Time::FromInternalValue(cookieSave.creation_date_), base::Time::FromInternalValue(cookieSave.last_access_date_), + cookieSave.has_expires_, base::Time::FromInternalValue(cookieSave.expiry_date_) ); + m_mapCookies.push_back( cookie ); + } + } + fclose( fp ); + if ( bOldCookieFile ) + QueueSave(); + + } +} + + +size_t CookieStore::AppendString( char *pchData, const std::string &str, size_t cbCurUsed ) +{ + if ( (cbCurUsed + (size_t)str.length() + sizeof(unsigned int)) > m_cbCookieDataAlloced ) + { + m_cbCookieDataAlloced = cbCurUsed + str.length()*2; + m_pchCookieData = (char *)realloc( m_pchCookieData, m_cbCookieDataAlloced ); + if ( !m_pchCookieData ) + { + return 0; + } + } + + unsigned int length = str.length(); + // write out a length prefixed string + memcpy( (void *)pchData, &length, sizeof(length) ); + memcpy( (void *)(pchData + sizeof(length)), str.c_str(), length ); // copy the null byte too + return length + sizeof(length); +} + + +size_t CookieStore::ReadString( const char *pchData, std::string &str ) +{ + unsigned int length = *(unsigned int *)pchData; + if ( length == 0 ) + { + str = ""; + return sizeof(length); + } + if ( length > 2048 ) + return 0; + + + pchData+=sizeof(length); + char *pchStrData = (char *)malloc(length + 1); + memcpy( pchStrData, pchData, length ); + pchStrData[ length ] = 0; + str = pchStrData; + free(pchStrData); + return length + sizeof(length); +} + + + +const char *CookieStore::SaveCookieRecord( const net::CookieMonster::CanonicalCookie& cookie, size_t *pOutputSize ) +{ + *pOutputSize = 0; + if ( !m_pchCookieData || m_cbCookieDataAlloced < 1024 ) + { + if ( m_pchCookieData ) + free( m_pchCookieData); + m_cbCookieDataAlloced = 1024; + m_pchCookieData = (char *)malloc( m_cbCookieDataAlloced ); + if ( !m_pchCookieData ) + return NULL; + } + + CookieSaveRecord *pSaveCookie = (CookieSaveRecord *)m_pchCookieData; + pSaveCookie->creation_date_ = cookie.CreationDate().ToInternalValue(); + pSaveCookie->last_access_date_ = cookie.LastAccessDate().ToInternalValue(); + pSaveCookie->expiry_date_ = cookie.ExpiryDate().ToInternalValue(); + pSaveCookie->has_expires_ = cookie.DoesExpire(); + pSaveCookie->secure_ = cookie.IsSecure(); + pSaveCookie->httponly_ = cookie.IsHttpOnly(); + + // okay, saved off the fixed stuff, now append the var length strings + char *pchStringData = m_pchCookieData + sizeof(CookieSaveRecord); + *pOutputSize += sizeof(CookieSaveRecord); + size_t lenUsed = AppendString( pchStringData, cookie.Name(), *pOutputSize ); + if ( lenUsed == 0 ) + { + *pOutputSize = 0; + return NULL; + } + *pOutputSize += lenUsed; + pchStringData += lenUsed; + + lenUsed = AppendString( pchStringData, cookie.Value(), *pOutputSize ); + if ( lenUsed == 0 ) + { + *pOutputSize = 0; + return NULL; + } + *pOutputSize += lenUsed; + pchStringData += lenUsed; + + lenUsed = AppendString( pchStringData, cookie.Path(), *pOutputSize ); + if ( lenUsed == 0 ) + { + *pOutputSize = 0; + return NULL; + } + *pOutputSize += lenUsed; + pchStringData += lenUsed; + + lenUsed = AppendString( pchStringData, cookie.Domain(), *pOutputSize ); + if ( lenUsed == 0 ) + { + *pOutputSize = 0; + return NULL; + } + *pOutputSize += lenUsed; + pchStringData += lenUsed; + + return m_pchCookieData; +} + + +size_t CookieStore::RestoreCookie( const char *pchDataIn, const int cbData, CookieSaveRecord *pCookieRecord, std::string &name, std::string &value, std::string &domain, std::string &path, std::string &key, int nCookieFileVersion ) +{ + const char *pchData = pchDataIn; + CookieSaveRecord *pCookieRecordStream = (CookieSaveRecord *)pchData; + pchData+=sizeof(CookieSaveRecord); + + pCookieRecord->creation_date_ = pCookieRecordStream->creation_date_; + pCookieRecord->expiry_date_ = pCookieRecordStream->expiry_date_; + pCookieRecord->has_expires_ = pCookieRecordStream->has_expires_; + pCookieRecord->httponly_ = pCookieRecordStream->httponly_; + pCookieRecord->last_access_date_ = pCookieRecordStream->last_access_date_; + pCookieRecord->secure_ = pCookieRecordStream->secure_; + + size_t len = ReadString( pchData, name ); + if ( len == 0 ) + return 0; + pchData += len; + + len = ReadString( pchData, value ); + if ( len == 0 ) + return 0; + pchData += len; + + len = ReadString( pchData, path ); + if ( len == 0 ) + return 0; + pchData += len; + + if ( nCookieFileVersion <= 1 ) + { + len = ReadString( pchData, key ); + if ( len == 0 ) + return 0; + pchData += len; + } + + if ( nCookieFileVersion > 1 ) + { + // ignore failure on domain + len = ReadString( pchData, domain ); + if ( len != 0 ) + pchData += len; + } + return ( pchData - pchDataIn ); +} +*/ Index: libcef/cef_context.h =================================================================== --- libcef/cef_context.h (revision 465) +++ libcef/cef_context.h (working copy) @@ -1,4 +1,4 @@ -// 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 // be found in the LICENSE file. @@ -20,6 +20,7 @@ #include "base/at_exit.h" #include "base/file_path.h" #include "base/memory/ref_counted.h" +#include "base/synchronization/waitable_event.h" // VALVE BUILD class CefBrowserImpl; class WebViewHost; @@ -36,7 +37,7 @@ ~CefContext(); // These methods will be called on the main application thread. - bool Initialize(const CefSettings& settings, CefRefPtr application); + bool Initialize(const CefSettings& settings, CefRefPtr application, const CefString pchResourceDll ); void Shutdown(); // Returns true if the context is initialized. @@ -51,10 +52,14 @@ bool RemoveBrowser(CefRefPtr browser); CefRefPtr GetBrowserByID(int id); BrowserList* GetBrowserList() { return &browserlist_; } - + // VALVE BUILD + void ClearHTMLCache(); + const std::wstring &GetResourceDllName() { return resource_dll_; } + // Retrieve the path at which cache data will be stored on disk. If empty, // cache data will be stored in-memory. const FilePath& cache_path() const { return cache_path_; } + const FilePath& cookie_path() { return cookie_path_; } const CefSettings& settings() const { return settings_; } CefRefPtr application() const { return application_; } @@ -94,6 +99,9 @@ void UIT_FinishShutdown(base::WaitableEvent* browser_shutdown_event, base::WaitableEvent* uithread_shutdown_event); + void ClearCacheOnIOThread(); // VALVE BUILD + void DoClearCache( int rv ); + // Track context state. bool initialized_; bool shutting_down_; @@ -108,15 +116,18 @@ CefSettings settings_; CefRefPtr application_; FilePath cache_path_; + FilePath cookie_path_; scoped_refptr request_context_; scoped_ptr storage_context_; BrowserFileSystem file_system_; + std::wstring resource_dll_; // Map of browsers that currently exist. BrowserList browserlist_; // Used for assigning unique IDs to browser instances. int next_browser_id_; + base::WaitableEvent clear_html_cache_completed_; // VALVE BUILD WebViewHost* current_webviewhost_; Index: libcef/cef_process_io_thread.cc =================================================================== --- libcef/cef_process_io_thread.cc (revision 465) +++ libcef/cef_process_io_thread.cc (working copy) @@ -19,6 +19,10 @@ #if defined(OS_WIN) #include // NOLINT(build/include_order) #endif +#if defined(OS_MACOSX) +extern "C" void *CreateAutoReleasePool(); +extern "C" void ReleaseAutoReleasePool( void *pool ); +#endif CefProcessIOThread::CefProcessIOThread() : CefThread(CefThread::IO), request_context_(NULL) {} @@ -37,6 +41,9 @@ // Initializes the COM library on the current thread. CoInitialize(NULL); #endif +#if defined(OS_MACOSX) + pool = CreateAutoReleasePool(); +#endif FilePath cache_path(_Context->cache_path()); request_context_ = new BrowserRequestContext(cache_path, @@ -64,7 +71,13 @@ _Context->set_request_context(NULL); request_context_ = NULL; - +#if defined(OS_MACOSX) + if ( pool ) + { + ReleaseAutoReleasePool( pool ); + pool = NULL; + } +#endif #if defined(OS_WIN) // Closes the COM library on the current thread. CoInitialize must // be balanced by a corresponding call to CoUninitialize. Index: libcef/cef_process_io_thread.h =================================================================== --- libcef/cef_process_io_thread.h (revision 465) +++ libcef/cef_process_io_thread.h (working copy) @@ -36,6 +36,9 @@ private: scoped_refptr request_context_; +#if defined(OS_MACOSX) // VALVE BUILD, auto-release pool + void *pool; +#endif DISALLOW_COPY_AND_ASSIGN(CefProcessIOThread); }; Index: libcef/cef_process_ui_thread.cc =================================================================== --- libcef/cef_process_ui_thread.cc (revision 465) +++ libcef/cef_process_ui_thread.cc (working copy) @@ -77,7 +77,7 @@ bool ret = icu_util::Initialize(); if (!ret) { #if defined(OS_WIN) - MessageBox(NULL, L"Failed to load the required icudt library", + MessageBox(NULL, L"Failed to load the required icudt38 library", L"CEF Initialization Error", MB_ICONERROR | MB_OK); #endif return; Index: libcef/cef_process_ui_thread_mac.mm =================================================================== --- libcef/cef_process_ui_thread_mac.mm (revision 465) +++ libcef/cef_process_ui_thread_mac.mm (working copy) @@ -5,6 +5,7 @@ #import +#define VALVE_BUILD #import "include/cef_application_mac.h" #include "libcef/cef_process_ui_thread.h" #include "libcef/browser_webkit_glue.h" @@ -14,14 +15,32 @@ void CefProcessUIThread::PlatformInit() { // The NSApplication instance must implement the CefAppProtocol protocol. - DCHECK([[NSApplication sharedApplication] - conformsToProtocol:@protocol(CefAppProtocol)]); + // VALVE BUILD - don't enforce the magic cefappprotocol requirement + //DCHECK([[NSApplication sharedApplication] + // conformsToProtocol:@protocol(CefAppProtocol)]); InitWebCoreSystemInterface(); +#ifdef VALVE_BUILD + WebKit::WebView::setUseExternalPopupMenus(false); +#else // On Mac, the select popup menus are rendered by the browser. WebKit::WebView::setUseExternalPopupMenus(true); +#endif } void CefProcessUIThread::PlatformCleanUp() { } + + +// VALVE BUILD +extern "C" void *CreateAutoReleasePool() +{ + return [[NSAutoreleasePool alloc] init]; +} + +extern "C" void ReleaseAutoReleasePool( void *pool ) +{ + [(NSAutoreleasePool *)pool release]; +} +// VALVE BUILD Index: libcef/osx_leopard_template_workaround.cpp =================================================================== --- libcef/osx_leopard_template_workaround.cpp (revision 0) +++ libcef/osx_leopard_template_workaround.cpp (working copy) @@ -0,0 +1,66 @@ +// Workarounds for symbols that are missing from Leopard stdlibc++.dylib. +_GLIBCXX_BEGIN_NAMESPACE(std) +// From ostream_insert.h +template ostream& __ostream_insert(ostream&, const char*, streamsize); + +#ifdef _GLIBCXX_USE_WCHAR_T + template wostream& __ostream_insert(wostream&, const wchar_t*, streamsize); +#endif + +// From ostream.tcc +template ostream& ostream::_M_insert(long); +template ostream& ostream::_M_insert(unsigned long); +template ostream& ostream::_M_insert(bool); +#ifdef _GLIBCXX_USE_LONG_LONG + template ostream& ostream::_M_insert(long long); + template ostream& ostream::_M_insert(unsigned long long); +#endif +template ostream& ostream::_M_insert(double); +template ostream& ostream::_M_insert(long double); +template ostream& ostream::_M_insert(const void*); + +#ifdef _GLIBCXX_USE_WCHAR_T + template wostream& wostream::_M_insert(long); + template wostream& wostream::_M_insert(unsigned long); + template wostream& wostream::_M_insert(bool); + #ifdef _GLIBCXX_USE_LONG_LONG + template wostream& wostream::_M_insert(long long); + template wostream& wostream::_M_insert(unsigned long long); + #endif + template wostream& wostream::_M_insert(double); + template wostream& wostream::_M_insert(long double); + template wostream& wostream::_M_insert(const void*); +#endif + +// From istream.tcc +template istream& istream::_M_extract(unsigned short&); +template istream& istream::_M_extract(unsigned int&); +template istream& istream::_M_extract(long&); +template istream& istream::_M_extract(unsigned long&); +template istream& istream::_M_extract(bool&); +#ifdef _GLIBCXX_USE_LONG_LONG + template istream& istream::_M_extract(long long&); + template istream& istream::_M_extract(unsigned long long&); +#endif +template istream& istream::_M_extract(float&); +template istream& istream::_M_extract(double&); +template istream& istream::_M_extract(long double&); +template istream& istream::_M_extract(void*&); + +#ifdef _GLIBCXX_USE_WCHAR_T + template wistream& wistream::_M_extract(unsigned short&); + template wistream& wistream::_M_extract(unsigned int&); + template wistream& wistream::_M_extract(long&); + template wistream& wistream::_M_extract(unsigned long&); + template wistream& wistream::_M_extract(bool&); + #ifdef _GLIBCXX_USE_LONG_LONG + template wistream& wistream::_M_extract(long long&); + template wistream& wistream::_M_extract(unsigned long long&); + #endif + template wistream& wistream::_M_extract(float&); + template wistream& wistream::_M_extract(double&); + template wistream& wistream::_M_extract(long double&); + template wistream& wistream::_M_extract(void*&); +#endif + +_GLIBCXX_END_NAMESPACE Index: libcef/printing/print_settings.cc =================================================================== --- libcef/printing/print_settings.cc (revision 465) +++ libcef/printing/print_settings.cc (working copy) @@ -37,8 +37,8 @@ desired_dpi(72), selection_only(false), to_file(false), - dpi_(0), - landscape(false) { + landscape(false), + dpi_(0) { ResetRequestedPageMargins(); } @@ -73,7 +73,7 @@ requested_margins.bottom = margin_printer_units; } -#ifdef WIN32 +#ifdef _WIN32 void PrintSettings::Init(HDC hdc, const DEVMODE& dev_mode, const PageRanges& new_ranges, Index: libcef/printing/win_printing_context.cc =================================================================== --- libcef/printing/win_printing_context.cc (revision 465) +++ libcef/printing/win_printing_context.cc (working copy) @@ -54,7 +54,8 @@ HWND window, int max_pages, bool has_selection) { - DCHECK(window); + if ( !window ) + window = ::GetForegroundWindow(); DCHECK(!in_print_job_); dialog_box_dismissed_ = false; // Show the OS-dependent dialog box. @@ -603,4 +604,3 @@ } } // namespace printing - Index: libcef/printing/win_printing_context.h =================================================================== --- libcef/printing/win_printing_context.h (revision 465) +++ libcef/printing/win_printing_context.h (working copy) @@ -147,5 +147,4 @@ }; } // namespace printing - #endif // CEF_LIBCEF_PRINTING_WIN_PRINTING_CONTEXT_H_ Index: libcef/request_impl.cc =================================================================== --- libcef/request_impl.cc (revision 465) +++ libcef/request_impl.cc (working copy) @@ -216,6 +216,15 @@ request.setHTTPHeaderField(string16(it->first), string16(it->second)); } +// VALVE BUILD +void CefRequestImpl::GetHeaderMap(const WebKit::WebURLResponse& response, + HeaderMap& map) +{ + HttpHeaderUtils::HeaderVisitor visitor(&map); + response.visitHTTPHeaderFields(&visitor); +} +// VALVE BUILD + CefRefPtr CefPostData::CreatePostData() { CefRefPtr postdata(new CefPostDataImpl()); return postdata; @@ -427,7 +436,7 @@ std::string(element.bytes().begin(), element.bytes().end()).c_str())); } else if (element.type() == net::UploadData::TYPE_FILE) { - SetToFile(element.file_path().value()); + SetToFile( element.file_path().value()); } else { NOTREACHED(); } @@ -472,4 +481,29 @@ } else { NOTREACHED(); } + } + + +CefSecurityDetailsImpl::CefSecurityDetailsImpl() +{ + m_bSecure = false; + m_bCertError = true; + m_tCertExpiry = 0; + m_nCertBits = -1; + m_bIsEVCert = false; +} + + +void CefSecurityDetailsImpl::SetParameters( bool bSecure, bool bCertError, const char *pchCommonName, const char *pchIssuer, + time_t expiry, int nCertBits, bool bIsEVCert ) +{ + m_bSecure = bSecure; + m_bCertError = bCertError; + m_sCommonName = pchCommonName; + m_sIssuer = pchIssuer; + m_tCertExpiry = expiry; + m_nCertBits = nCertBits; + m_bIsEVCert = bIsEVCert; +} + Index: libcef/request_impl.h =================================================================== --- libcef/request_impl.h (revision 465) +++ libcef/request_impl.h (working copy) @@ -11,6 +11,7 @@ #include "net/http/http_request_headers.h" #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebHTTPBody.h" #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURLRequest.h" +#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURLResponse.h" namespace net { class URLRequest; @@ -47,9 +48,14 @@ HeaderMap& map); static void GetHeaderMap(const WebKit::WebURLRequest& request, HeaderMap& map); + static void GetHeaderMap(const WebKit::WebURLResponse& headers, + HeaderMap& map); static void SetHeaderMap(const HeaderMap& map, WebKit::WebURLRequest& request); + virtual void SetSecurityDetails( CefRefPtr securityData ) { security_data_ = securityData; } + virtual bool BIsSecureRequest() { return security_data_->BIsSecure(); } + virtual CefRefPtr SecurityDetails() { return security_data_; } protected: CefString url_; CefString method_; @@ -59,6 +65,7 @@ // The below methods are used by WebURLRequest. RequestFlags flags_; CefString first_party_for_cookies_; + CefRefPtr security_data_; IMPLEMENT_REFCOUNTING(CefRequestImpl); IMPLEMENT_LOCKING(CefRequestImpl); @@ -123,4 +130,40 @@ IMPLEMENT_LOCKING(CefPostDataElementImpl); }; +// Class used to represent the security settings for a page +/*--cef(source=library)--*/ +class CefSecurityDetailsImpl : public CefSecurityDetails +{ +public: + CefSecurityDetailsImpl(); + virtual ~CefSecurityDetailsImpl() {} + + // CefSecurityDetails impl + virtual bool BIsSecure() { return m_bSecure; } + virtual bool BHasCertError() { return m_bCertError; } + virtual CefString PchCertCommonName() { return m_sCommonName.c_str(); } + virtual CefString PchCertIssuer() { return m_sIssuer.c_str(); } + virtual time_t TCertExpiry() { return m_tCertExpiry; } + virtual int NCertBits() { return m_nCertBits; } + virtual bool BIsEVCert() { return m_bIsEVCert; } + + // setters + void SetParameters( bool bSecure, bool bCertError, const char *pchCommonName, const char *pchIssuer, + time_t expiry, int nCertBits, bool bIsEVCert ); + +protected: + bool m_bSecure; + bool m_bCertError; + std::string m_sCommonName; + std::string m_sIssuer; + time_t m_tCertExpiry; + int m_nCertBits; + bool m_bIsEVCert; + + IMPLEMENT_REFCOUNTING(CefSecurityDetailsImpl); + IMPLEMENT_LOCKING(CefSecurityDetailsImpl); + +}; + + #endif // CEF_LIBCEF_REQUEST_IMPL_H_ Index: libcef/scheme_impl.cc =================================================================== --- libcef/scheme_impl.cc (revision 465) +++ libcef/scheme_impl.cc (working copy) @@ -318,6 +318,7 @@ NewRunnableMethod(this, &Callback::BytesAvailable)); } } + virtual void Cancel() OVERRIDE { if (CefThread::CurrentlyOn(CefThread::IO)) { Index: libcef/stream_impl.cc =================================================================== --- libcef/stream_impl.cc (revision 465) +++ libcef/stream_impl.cc (working copy) @@ -6,6 +6,8 @@ #include #include "base/logging.h" +#include + // Static functions CefRefPtr CefStreamReader::CreateForFile( Index: libcef/webview_host_mac.mm =================================================================== --- libcef/webview_host_mac.mm (revision 465) +++ libcef/webview_host_mac.mm (working copy) @@ -33,13 +33,19 @@ WebDevToolsAgentClient* dev_tools_client, const WebPreferences& prefs) { WebViewHost* host = new WebViewHost(delegate); - NSRect content_rect = {{rect.x(), rect.y()}, {rect.width(), rect.height()}}; - host->view_ = [[BrowserWebView alloc] initWithFrame:content_rect]; - [host->view_ setAutoresizingMask:(NSViewWidthSizable | NSViewHeightSizable)]; - [parent_view addSubview:host->view_]; - [host->view_ release]; + if (!paint_delegate) { + host->view_ = [[BrowserWebView alloc] initWithFrame:content_rect]; + [host->view_ setAutoresizingMask:(NSViewWidthSizable | NSViewHeightSizable)]; + [parent_view addSubview:host->view_]; + [host->view_ release]; + } + else { + host->paint_delegate_ = paint_delegate; + + } + #if defined(WEBKIT_HAS_WEB_AUTO_FILL_CLIENT) host->webwidget_ = WebView::create(delegate, NULL); #else Index: libcef/webwidget_host.cc =================================================================== --- libcef/webwidget_host.cc (revision 465) +++ libcef/webwidget_host.cc (working copy) @@ -9,7 +9,18 @@ #include "base/message_loop.h" #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebSize.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebWidget.h" +// VALVE BUILD +#include "webkit/glue/user_agent.h" +#include "webkit/glue/webkit_glue.h" +#include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" +#include "third_party/WebKit/Source/WebKit/chromium/public/WebPopupMenu.h" +#include "third_party/WebKit/Source/WebKit/chromium/public/WebScreenInfo.h" +#include "third_party/WebKit/Source/WebKit/chromium/public/WebCursorInfo.h" +#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebSize.h" +#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebPoint.h" +// VALVE BUILD + using webkit::npapi::WebPluginGeometry; using WebKit::WebSize; @@ -57,6 +68,8 @@ } void WebWidgetHost::SetSize(int width, int height) { + if ( width == size_rect.width() && height == size_rect.height() ) + return; webwidget_->resize(WebSize(width, height)); DidInvalidateRect(gfx::Rect(0, 0, width, height)); EnsureTooltip(); @@ -110,7 +123,6 @@ // currently requires patches to Chromium. Since this code is only executed // on Windows it's been stuck behind an #ifdef for now to avoid having to // patch Chromium code on other platforms. -#if defined(OS_WIN) if (MessageLoop::current()->IsIdle()) { has_update_task_ = false; // Paint to the delegate. @@ -120,7 +132,102 @@ CefThread::PostTask(CefThread::UI, FROM_HERE, base::Bind(&WebWidgetHost::DoPaint, weak_factory_.GetWeakPtr())); } -#else - NOTIMPLEMENTED(); -#endif } + +#ifdef VALVE_BUILD +// VALVE added interfaces +bool WebWidgetHost::IsVisuallyNonEmpty() +{ + return webwidget_->isVisuallyNonEmpty(); +} + + +void WebWidgetHost::SetBrowserGlobalPosition( int x, int y ) +{ + size_rect.set_x( x ); + size_rect.set_y( y ); +} + +void WebWidgetHost::SetShowScrollBars( bool bShow ) +{ + webwidget_->setShowScrollBars(bShow); +} + +void WebWidgetHost::HorizontalScrollBarSize(int &x, int &y, int &wide, int &tall) +{ + WebKit::WebRect rect = webwidget_->horizontalScrollBarSize(); + x = rect.x; + y= rect.y; + wide = rect.width; + tall = rect.height; +} + +void WebWidgetHost::VerticalScrollBarSize(int &x, int &y, int &wide, int &tall) +{ + WebKit::WebRect rect = webwidget_->verticalScrollBarSize(); + x = rect.x; + y= rect.y; + wide = rect.width; + tall = rect.height; +} + +int WebWidgetHost::HorizontalScroll() +{ + return webwidget_->horizontalScroll(); +} + +int WebWidgetHost::VerticalScroll() +{ + return webwidget_->verticalScroll(); +} + +bool WebWidgetHost::IsHorizontalScrollBarVisible() +{ + return webwidget_->isHorizontalScrollBarVisible(); +} + +bool WebWidgetHost::IsVeritcalScrollBarVisible() +{ + return webwidget_->isVeritcalScrollBarVisible(); +} + +int WebWidgetHost::HorizontalScrollMax() +{ + return webwidget_->horizontalScrollMax(); +} + +int WebWidgetHost::VerticalScrollMax() +{ + return webwidget_->verticalScrollMax(); +} + +void WebWidgetHost::SetHorizontalScroll( int scroll ) +{ + return webwidget_->setHorizontalScroll( scroll ); +} + +void WebWidgetHost::SetVerticalScroll( int scroll ) +{ + return webwidget_->setVerticalScroll( scroll ); +} + +void WebWidgetHost::SetUserAgent( const char *pchUserAgent ) +{ + webkit_glue::SetUserAgent( pchUserAgent, true ); +} + + +const char *WebWidgetHost::GetLinkAtPosition( int x, int y ) +{ + m_LinkAtPosURL = webwidget_->GetURLForPoint( WebKit::WebPoint( x, y ) ); + if ( m_LinkAtPosURL.isValid() ) + return m_LinkAtPosURL.spec().data(); + return NULL; +} + +int WebWidgetHost::zoomToElementAt( int x, int y,int max_width, int max_height, int min_block_width, int min_block_height, WebKit::WebRect &initialRect, WebKit::WebRect &finalRect ) +{ + return webwidget_->zoomToElementAt( x, y, max_width, max_height, min_block_width, min_block_height, initialRect, finalRect ); +} +#endif // VALVE BUILD + Index: libcef/webwidget_host.h =================================================================== --- libcef/webwidget_host.h (revision 465) +++ libcef/webwidget_host.h (working copy) @@ -22,6 +22,7 @@ #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebRect.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebTextInputType.h" +#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURL.h" #include "third_party/skia/include/core/SkRegion.h" #include "ui/gfx/native_widget_types.h" #include "ui/gfx/rect.h" @@ -35,6 +36,10 @@ #include // NOLINT(build/include_order) #endif +// VALVE BUILD +#define VALVE_BUILD +// VALVE BUILD + namespace gfx { class Rect; class Size; @@ -45,6 +50,7 @@ class WebWidgetClient; class WebKeyboardEvent; struct WebScreenInfo; +struct WebRect; } #if defined(OS_MACOSX) @@ -102,11 +108,7 @@ // is called. This is only used when window rendering is disabled. void UpdateRedrawRect(const gfx::Rect& rect); -#if defined(OS_MACOSX) - void Paint(SkRegion& update_rgn); -#else void Paint(); -#endif void InvalidateRect(const gfx::Rect& rect); bool GetImage(int width, int height, void* buffer); @@ -120,6 +122,33 @@ WebKit::WebKeyboardEvent GetLastKeyEvent() const { return last_key_event_; } + // VALVE - added interface +#ifdef VALVE_BUILD + void SetBrowserGlobalPosition( int x, int y ); // position in abs screen space + void SetShowScrollBars( bool bShow ); + void HorizontalScrollBarSize( int &x, int &y, int &wide, int &tall); + void VerticalScrollBarSize( int &x, int &y, int &wide, int &tall); + int HorizontalScroll(); + int VerticalScroll(); + int HorizontalScrollMax(); + int VerticalScrollMax(); + bool IsHorizontalScrollBarVisible(); + bool IsVeritcalScrollBarVisible(); + void SetHorizontalScroll( int scroll ); + void SetVerticalScroll( int scroll ); + void SetUserAgent( const char *pchUserAgent ); + + int texture_id_; + gfx::Rect size_rect; + WebKit::WebURL m_LinkAtPosURL; + void SetupEventPosition( WebKit::WebMouseEvent &event ); + bool IsVisuallyNonEmpty(); + const char *GetLinkAtPosition( int x, int y ); + int zoomToElementAt( int x, int y,int max_width, int max_height, int min_block_width, int min_block_height, WebKit::WebRect &initialRect, WebKit::WebRect &finalRect ); + int setZoomFactor( double zoomFactor ); +#endif + // VALVE - added interface + void PaintRect(const gfx::Rect& rect); void SetTooltipText(const CefString& tooltip_text); @@ -264,6 +293,9 @@ #if defined(OS_WIN) bool track_mouse_leave_; std::wstring tooltip_text_; + bool supports_hwnd_painting_; + int mouse_modifiers_; + WebKit::WebMouseEvent::Button mouse_button_down_; gfx::NativeView tooltip_view_; bool tooltip_showing_; Index: libcef/webwidget_host_mac.mm =================================================================== --- libcef/webwidget_host_mac.mm (revision 465) +++ libcef/webwidget_host_mac.mm (working copy) @@ -3,7 +3,10 @@ // found in the LICENSE file. #import +#include #import "libcef/webwidget_host.h" +#import "libcef/cef_thread.h" +#import "base/bind.h" #import "base/logging.h" #import "skia/ext/platform_canvas.h" #import "third_party/WebKit/Source/WebKit/chromium/public/mac/WebInputEventFactory.h" @@ -17,6 +20,7 @@ #import "ui/gfx/size.h" #import "webkit/glue/webkit_glue.h" +using webkit::npapi::WebPluginGeometry; using WebKit::WebInputEvent; using WebKit::WebInputEventFactory; using WebKit::WebKeyboardEvent; @@ -46,14 +50,21 @@ PaintDelegate* paint_delegate) { WebWidgetHost* host = new WebWidgetHost(); - const NSRect bounds = [parent_view bounds]; - host->view_ = [[NSView alloc] initWithFrame:bounds]; - [parent_view addSubview:host->view_]; - host->painting_ = false; host->layouting_ = false; - host->webwidget_ = WebPopupMenu::create(client); - host->webwidget_->resize(WebSize(NSWidth(bounds), NSHeight(bounds))); + + if (!paint_delegate) { + const NSRect bounds = [parent_view bounds]; + host->view_ = [[NSView alloc] initWithFrame:bounds]; + [parent_view addSubview:host->view_]; + host->webwidget_ = WebPopupMenu::create(client); + host->webwidget_->resize(WebSize(NSWidth(bounds), NSHeight(bounds))); + } else { + host->view_ = NULL; + host->paint_delegate_ = paint_delegate; + host->webwidget_ = WebPopupMenu::create(client); + } + return host; } @@ -74,21 +85,41 @@ } void WebWidgetHost::DidInvalidateRect(const gfx::Rect& damaged_rect) { - const gfx::Rect client_rect(NSRectToCGRect([view_ bounds])); + int width, height; + GetSize(width, height); + const gfx::Rect client_rect(width, height); + +// const gfx::Rect client_rect(NSRectToCGRect([view_ bounds])); + const gfx::Rect damaged_rect_in_client = client_rect.Intersect(damaged_rect); if (!damaged_rect_in_client.IsEmpty()) { UpdatePaintRect(damaged_rect_in_client); - NSRect cocoa_rect = NSRectFromCGRect(damaged_rect_in_client.ToCGRect()); - cocoa_rect.origin.y = client_rect.height() - NSMaxY(cocoa_rect); - [view_ setNeedsDisplayInRect:cocoa_rect]; + + if ( view_ ) { + NSRect cocoa_rect = NSRectFromCGRect(damaged_rect_in_client.ToCGRect()); + cocoa_rect.origin.y = client_rect.height() - NSMaxY(cocoa_rect); + [view_ setNeedsDisplayInRect:cocoa_rect]; + } else { + // Don't post a paint task if this invalidation occurred during layout or if + // a paint task is already pending. Paint() will be called by DoPaint(). + if (!layouting_ && !has_update_task_) { + has_update_task_ = true; + CefThread::PostTask(CefThread::UI, FROM_HERE, + base::Bind(&WebWidgetHost::DoPaint, weak_factory_.GetWeakPtr())); + } + } } } void WebWidgetHost::DidScrollRect(int dx, int dy, const gfx::Rect& clip_rect) { DCHECK(dx || dy); + + int width, height; + GetSize(width, height); + const gfx::Rect client_rect(width, height); - const gfx::Rect client_rect(NSRectToCGRect([view_ bounds])); + //const gfx::Rect client_rect(NSRectToCGRect([view_ bounds])); gfx::Rect rect = clip_rect.Intersect(client_rect); const int x = rect.x(); @@ -106,7 +137,7 @@ // needs to be laid out; calling scrollRect:by: in this situation leads to // unwanted behavior. Finally, scrolling the rectangle by more than the size // of the view means we can just invalidate the entire scroll rect. - if (![view_ canDraw] || painting_ || layouting_ || Dx >= w || Dy >= h) { + if (!view_ || ![view_ canDraw] || painting_ || layouting_ || Dx >= w || Dy >= h) { DidInvalidateRect(clip_rect); return; } @@ -143,7 +174,9 @@ DidInvalidateRect(convertFromSkiaRect(moved_paint_rgn.getBounds())); } -void WebWidgetHost::Paint(SkRegion& update_rgn) { +// VALVE BUILD +void WebWidgetHost::Paint() { + /* gfx::Rect client_rect(NSRectToCGRect([view_ bounds])); // Union the rectangle that WebKit think needs repainting with the rectangle @@ -153,7 +186,7 @@ // itself. However, if we don't do this we can get artifacts when scrolling // because contents of the canvas are no longer correct after scrolling only // in the view. - paint_rgn_.op(update_rgn, SkRegion::kUnion_Op); + //paint_rgn_.op(update_rgn, SkRegion::kUnion_Op); // When we are not using accelerated compositing the canvas area is allowed // to differ in size from the client by a certain number of pixels (128 in @@ -194,6 +227,8 @@ [NSGraphicsContext saveGraphicsState]; [NSGraphicsContext setCurrentContext:paint_context]; + SkRegion update_rgn = paint_rgn_; + // Paint the canvas if necessary. The painting operation can cause additional // regions to be invalidated because some elements are laid out the first time // they are painted. @@ -208,24 +243,153 @@ // If any more rectangles were made dirty during the paint operation, make // sure they are copied to the window buffer, by including the paint region. // If nothing needs additional painting, this is a no-op. - update_rgn.op(paint_rgn_, SkRegion::kUnion_Op); - } + //update_rgn.op(paint_rgn_, SkRegion::kUnion_Op); + }*/ + + int width, height; + GetSize(width, height); + gfx::Rect client_rect(width, height); + + // Damaged rectangle used for drawing when window rendering is disabled. + SkRegion damaged_rgn; + if (!view_ && !redraw_rect_.IsEmpty()) { + // At a minimum we need to send the delegate the rectangle that was + // requested by calling CefBrowser::InvalidateRect(). + damaged_rgn.setRect(convertToSkiaRect(redraw_rect_)); + redraw_rect_ = gfx::Rect(); + } + + + if ( view_ ) { + client_rect = NSRectToCGRect([view_ bounds]); + // When we are not using accelerated compositing the canvas area is allowed + // to differ in size from the client by a certain number of pixels (128 in + // this case). When accelerated compositing is in effect the size must match + // exactly. + const int extra_w = (webwidget_->isAcceleratedCompositingActive()? 0: 128); + const int extra_h = (webwidget_->isAcceleratedCompositingActive()? 0: 128); + const int min_w = client_rect.width(); + const int min_h = client_rect.height(); + const int max_w = client_rect.width() + extra_w * 2; + const int max_h = client_rect.height() + extra_h * 2; + + const bool too_small = (canvas_w_ < min_w || canvas_h_ < min_h); + const bool too_large = (canvas_w_ > max_w || canvas_h_ > max_h); + + if (!canvas_.get() || too_small || too_large) { + canvas_w_ = client_rect.width() + extra_w; + canvas_h_ = client_rect.height() + extra_h; + canvas_.reset(new skia::PlatformCanvas(canvas_w_, canvas_h_, true)); + paint_rgn_.setRect(convertToSkiaRect(client_rect)); + } + + // Draw into the graphics context of the canvas instead of the view's context. + // The view's context is pushed onto the context stack to be restored below. + CGContextRef bitmap = skia::GetBitmapContext(skia::GetTopDevice(*canvas_)); + NSGraphicsContext* paint_context = + [NSGraphicsContext graphicsContextWithGraphicsPort:bitmap flipped:YES]; + [NSGraphicsContext saveGraphicsState]; + [NSGraphicsContext setCurrentContext:paint_context]; - // Set the context back to our view and copy the bitmap that we just painted - // into to the view. Only the regions that were updated are copied. - [NSGraphicsContext restoreGraphicsState]; - NSGraphicsContext* view_context = [NSGraphicsContext currentContext]; - CGContextRef context = static_cast([view_context graphicsPort]); + } else if (!canvas_.get() || canvas_w_ != client_rect.width() || + canvas_h_ != client_rect.height() ) { + paint_rgn_.setRect(convertToSkiaRect(client_rect)); + + // The canvas must be the exact size of the client area. + canvas_w_ = client_rect.width(); + canvas_h_ = client_rect.height(); + canvas_.reset(new skia::PlatformCanvas(canvas_w_, canvas_h_, true)); + } - SkRegion::Cliperator iterator(update_rgn, convertToSkiaRect(client_rect)); - for (; !iterator.done(); iterator.next()) { - const SkIRect& r = iterator.rect(); - CGRect copy_rect = { { r.x(), r.y() }, { r.width(), r.height() } }; - const float x = r.x(); - const float y = client_rect.height() - r.bottom(); - skia::DrawToNativeContext(canvas_.get(), context, x, y, ©_rect); + webwidget_->animate(0.0); + + // Layout any views that have not been laid out yet. The layout may result in + // more invalidation. Keep track of the fact that we are laying out views, + // because this will sometimes cause ScrollRect to be called and we don't want + // to try to scrollRect:by: then. + layouting_ = true; + webwidget_->layout(); + layouting_ = false; + + + // Paint the canvas if necessary. Allow painting to generate extra rects the + // first time we call it. This is necessary because some WebCore rendering + // objects update their layout only when painted. + for (int i = 0; i < 2; ++i) { + SkRegion draw_rgn; + draw_rgn.swap(paint_rgn_); + + // Draw each dirty rect in the region. + SkRegion::Cliperator iterator(draw_rgn, convertToSkiaRect(client_rect)); + for (; !iterator.done(); iterator.next()) { + const SkIRect& r = iterator.rect(); + gfx::Rect paint_rect = + gfx::Rect(r.left(), r.top(), r.width(), r.height()); + PaintRect(paint_rect); + + if (!view_) + damaged_rgn.op(convertToSkiaRect(paint_rect), SkRegion::kUnion_Op); + } + + if (paint_rgn_.isEmpty()) + break; + } + + DCHECK(paint_rgn_.isEmpty()); + + if (!view_ && plugin_map_.size() > 0) { + typedef std::list PluginList; + PluginList visible_plugins; + + // Identify the visible plugins. + PluginMap::const_iterator it = plugin_map_.begin(); + for (; it != plugin_map_.end(); ++it) { + if (it->second.visible && client_rect.Intersects(it->second.window_rect)) + visible_plugins.push_back(&it->second); + } + + if (!visible_plugins.empty()) { + // flash seems to stop calling NPN_InvalidateRect, which means we stop + // painting, if we've got a plugin, make sure we paint its rect each time + const WebPluginGeometry* geom = &it->second; + damaged_rgn.op( convertToSkiaRect(geom->window_rect) , SkRegion::kUnion_Op); + } + } + + if (view_) { + + // Set the context back to our view and copy the bitmap that we just painted + // into to the view. Only the regions that were updated are copied. + [NSGraphicsContext restoreGraphicsState]; + NSGraphicsContext* view_context = [NSGraphicsContext currentContext]; + CGContextRef context = static_cast([view_context graphicsPort]); + + SkRegion::Cliperator iterator(damaged_rgn, convertToSkiaRect(client_rect)); + for (; !iterator.done(); iterator.next()) { + const SkIRect& r = iterator.rect(); + CGRect copy_rect = { { r.x(), r.y() }, { r.width(), r.height() } }; + const float x = r.x(); + const float y = client_rect.height() - r.bottom(); + skia::DrawToNativeContext(canvas_.get(), context, x, y, ©_rect); + } + } else { + // Paint to the delegate. + DCHECK(paint_delegate_); + const SkBitmap& bitmap = canvas_->getDevice()->accessBitmap(false); + DCHECK(bitmap.config() == SkBitmap::kARGB_8888_Config); + const void* pixels = bitmap.getPixels(); + + std::vector damaged_rects; + SkRegion::Cliperator iterator(damaged_rgn, convertToSkiaRect(client_rect)); + for (; !iterator.done(); iterator.next()) { + const SkIRect& r = iterator.rect(); + damaged_rects.push_back( + CefRect(r.left(), r.top(), r.width(), r.height())); + } + + paint_delegate_->Paint(popup_, damaged_rects, pixels); } - + // Used with scheduled invalidation to maintain a consistent frame rate. paint_last_call_ = base::TimeTicks::Now(); if (has_invalidate_task_) @@ -233,7 +397,12 @@ } void WebWidgetHost::Invalidate() { - [view_ setNeedsDisplay:YES]; + if ( view_ ) + [view_ setNeedsDisplay:YES]; + else if ( webwidget_ ) { + WebSize size = webwidget_->size(); + InvalidateRect(gfx::Rect(0, 0, size.width, size.height)); + } } void WebWidgetHost::SetTooltipText(const CefString& tooltip_text) { @@ -241,17 +410,48 @@ } void WebWidgetHost::InvalidateRect(const gfx::Rect& rect) { - // TODO(port): Implement this method as part of off-screen rendering support. - NOTIMPLEMENTED(); + if ( rect.IsEmpty() ) + return; + if (view_) { + NOTIMPLEMENTED(); + } else { + // Don't post a paint task if this invalidation occurred during layout or if + // a paint task is already pending. Paint() will be called by DoPaint(). + if (!layouting_ && !has_update_task_) { + has_update_task_ = true; + CefThread::PostTask(CefThread::UI, FROM_HERE, + base::Bind(&WebWidgetHost::DoPaint, weak_factory_.GetWeakPtr())); + } + } } bool WebWidgetHost::GetImage(int width, int height, void* rgba_buffer) { if (!canvas_.get()) return false; - // TODO(port): Implement this method as part of off-screen rendering support. - NOTIMPLEMENTED(); - return false; + const SkBitmap& bitmap = canvas_->getDevice()->accessBitmap(false); + DCHECK(bitmap.config() == SkBitmap::kARGB_8888_Config); + + if (width == canvas_->getDevice()->width() && + height == canvas_->getDevice()->height()) { + // The specified width and height values are the same as the canvas size. + // Return the existing canvas contents. + const void* pixels = bitmap.getPixels(); + memcpy(rgba_buffer, pixels, width * height * 4); + return true; + } + + // Create a new canvas of the requested size. + scoped_ptr new_canvas( new skia::PlatformCanvas(width, height, true)); + + new_canvas->writePixels(bitmap, 0, 0); + const SkBitmap& new_bitmap = new_canvas->getDevice()->accessBitmap(false); + DCHECK(new_bitmap.config() == SkBitmap::kARGB_8888_Config); + + // Return the new canvas contents. + const void* pixels = new_bitmap.getPixels(); + memcpy(rgba_buffer, pixels, width * height * 4); + return true; } WebScreenInfo WebWidgetHost::GetScreenInfo() { @@ -333,43 +533,519 @@ } } + +// convert the OSX scan code into the win32 VK code +static int windowsKeyCodeForKeyEventCode( int keyCode ) +{ + switch (keyCode) { + // VK_TAB (09) TAB key + case 48: + return 0x09; + + // VK_APPS (5D) Right windows/meta key + case 54: // Right Command + return 0x5D; + + // VK_LWIN (5B) Left windows/meta key + case 55: // Left Command + return 0x5B; + + // VK_CAPITAL (14) caps locks key + case 57: // Capslock + return 0x14; + + // VK_SHIFT (10) either shift key + case 56: // Left Shift + case 60: // Right Shift + return 0x10; + + // VK_MENU (12) either alt key + case 58: // Left Alt + case 61: // Right Alt + return 0x12; + + // VK_CONTROL (11) either ctrl key + case 59: // Left Ctrl + case 62: // Right Ctrl + return 0x11; + + // Begin non-Apple addition --------------------------------------------------- + case 63: // Function (no Windows key code) + return 0; + // End non-Apple addition ----------------------------------------------------- + + // VK_CLEAR (0C) CLEAR key + case 71: return 0x0C; + + // VK_NUMPAD0 (60) Numeric keypad 0 key + case 82: return 0x60; + // VK_NUMPAD1 (61) Numeric keypad 1 key + case 83: return 0x61; + // VK_NUMPAD2 (62) Numeric keypad 2 key + case 84: return 0x62; + // VK_NUMPAD3 (63) Numeric keypad 3 key + case 85: return 0x63; + // VK_NUMPAD4 (64) Numeric keypad 4 key + case 86: return 0x64; + // VK_NUMPAD5 (65) Numeric keypad 5 key + case 87: return 0x65; + // VK_NUMPAD6 (66) Numeric keypad 6 key + case 88: return 0x66; + // VK_NUMPAD7 (67) Numeric keypad 7 key + case 89: return 0x67; + // VK_NUMPAD8 (68) Numeric keypad 8 key + case 91: return 0x68; + // VK_NUMPAD9 (69) Numeric keypad 9 key + case 92: return 0x69; + // VK_MULTIPLY (6A) Multiply key + case 67: return 0x6A; + // VK_ADD (6B) Add key + case 69: return 0x6B; + + // VK_SUBTRACT (6D) Subtract key + case 78: return 0x6D; + // VK_DECIMAL (6E) Decimal key + case 65: return 0x6E; + // VK_DIVIDE (6F) Divide key + case 75: return 0x6F; + + // VK_LBUTTON (01) Left mouse button + // VK_RBUTTON (02) Right mouse button + // VK_CANCEL (03) Control-break processing + // VK_MBUTTON (04) Middle mouse button (three-button mouse) + // VK_XBUTTON1 (05) + // VK_XBUTTON2 (06) + + // VK_BACK (08) BACKSPACE key + case 51: return 0x08; + + // VK_CLEAR (0C) CLEAR key + // handled by key code above + + // VK_RETURN (0D) + case 36: return 0x0D; + + // VK_SHIFT (10) SHIFT key + // VK_CONTROL (11) CTRL key + // VK_MENU (12) ALT key + + // VK_PAUSE (13) PAUSE key + //case NSPauseFunctionKey: return 0x13; + + // VK_CAPITAL (14) CAPS LOCK key + // VK_KANA (15) Input Method Editor (IME) Kana mode + // VK_HANGUEL (15) IME Hanguel mode (maintained for compatibility; use VK_HANGUL) + // VK_HANGUL (15) IME Hangul mode + // VK_JUNJA (17) IME Junja mode + // VK_FINAL (18) IME final mode + // VK_HANJA (19) IME Hanja mode + // VK_KANJI (19) IME Kanji mode + + // VK_ESCAPE (1B) ESC key + case 53: return 0x1B; + + // VK_CONVERT (1C) IME convert + // VK_NONCONVERT (1D) IME nonconvert + // VK_ACCEPT (1E) IME accept + // VK_MODECHANGE (1F) IME mode change request + + // VK_SPACE (20) SPACEBAR + case 49: return 0x20; + // VK_PRIOR (21) PAGE UP key + case 116: return 0x21; + // VK_NEXT (22) PAGE DOWN key + case 121: return 0x22; + // VK_END (23) END key + case 119: return 0x23; + // VK_HOME (24) HOME key + case 115: return 0x24; + // VK_LEFT (25) LEFT ARROW key + case 123: return 0x25; + // VK_UP (26) UP ARROW key + case 126: return 0x26; + // VK_RIGHT (27) RIGHT ARROW key + case 124: return 0x27; + // VK_DOWN (28) DOWN ARROW key + case 125: return 0x28; + // VK_SELECT (29) SELECT key + //case NSSelectFunctionKey: return 0x29; + // VK_PRINT (2A) PRINT key + //case NSPrintFunctionKey: return 0x2A; + // VK_EXECUTE (2B) EXECUTE key + //case NSExecuteFunctionKey: return 0x2B; + // VK_SNAPSHOT (2C) PRINT SCREEN key + //case NSPrintScreenFunctionKey: return 0x2C; + // VK_INSERT (2D) INS key + case 114: return 0x2D; + // VK_DELETE (2E) DEL key + case 117: return 0x2E; + + // VK_HELP (2F) HELP key + + // (30) 0 key + case 29: return 0x30; + // (31) 1 key + case 18: return 0x31; + // (32) 2 key + case 19: return 0x32; + // (33) 3 key + case 20: return 0x33; + // (34) 4 key + case 21: return 0x34; + // (35) 5 key + case 23: return 0x35; + // (36) 6 key + case 22: return 0x36; + // (37) 7 key + case 26: return 0x37; + // (38) 8 key + case 28: return 0x38; + // (39) 9 key + case 25: return 0x39; + // (41) A key + case 0: return 0x41; + // (42) B key + case 11: return 0x42; + // (43) C key + case 8: return 0x43; + // (44) D key + case 2: return 0x44; + // (45) E key + case 14: return 0x45; + // (46) F key + case 3: return 0x46; + // (47) G key + case 5: return 0x47; + // (48) H key + case 4: return 0x48; + // (49) I key + case 34: return 0x49; + // (4A) J key + case 38: return 0x4A; + // (4B) K key + case 40: return 0x4B; + // (4C) L key + case 37: return 0x4C; + // (4D) M key + case 46: return 0x4D; + // (4E) N key + case 45: return 0x4E; + // (4F) O key + case 31: return 0x4F; + // (50) P key + case 35: return 0x50; + // (51) Q key + case 12: return 0x51; + // (52) R key + case 15: return 0x52; + // (53) S key + case 1: return 0x53; + // (54) T key + case 17: return 0x54; + // (55) U key + case 32: return 0x55; + // (56) V key + case 9: return 0x56; + // (57) W key + case 13: return 0x57; + // (58) X key + case 7: return 0x58; + // (59) Y key + case 16: return 0x59; + // (5A) Z key + case 6: return 0x5A; + + // VK_LWIN (5B) Left Windows key (Microsoft Natural keyboard) + // VK_RWIN (5C) Right Windows key (Natural keyboard) + // VK_APPS (5D) Applications key (Natural keyboard) + // VK_SLEEP (5F) Computer Sleep key + + // VK_NUMPAD0 (60) Numeric keypad 0 key + // VK_NUMPAD1 (61) Numeric keypad 1 key + // VK_NUMPAD2 (62) Numeric keypad 2 key + // VK_NUMPAD3 (63) Numeric keypad 3 key + // VK_NUMPAD4 (64) Numeric keypad 4 key + // VK_NUMPAD5 (65) Numeric keypad 5 key + // VK_NUMPAD6 (66) Numeric keypad 6 key + // VK_NUMPAD7 (67) Numeric keypad 7 key + // VK_NUMPAD8 (68) Numeric keypad 8 key + // VK_NUMPAD9 (69) Numeric keypad 9 key + // VK_MULTIPLY (6A) Multiply key + // VK_ADD (6B) Add key + // handled by key code above + + // VK_SEPARATOR (6C) Separator key + + // VK_SUBTRACT (6D) Subtract key + // VK_DECIMAL (6E) Decimal key + // VK_DIVIDE (6F) Divide key + // handled by key code above + + // VK_F1 (70) F1 key + case 122: return 0x70; + // VK_F2 (71) F2 key + case 120: return 0x71; + // VK_F3 (72) F3 key + case 99: return 0x72; + // VK_F4 (73) F4 key + case 118: return 0x73; + // VK_F5 (74) F5 key + case 96: return 0x74; + // VK_F6 (75) F6 key + case 97: return 0x75; + // VK_F7 (76) F7 key + case 98: return 0x76; + // VK_F8 (77) F8 key + case 100: return 0x77; + // VK_F9 (78) F9 key + case 101: return 0x78; + // VK_F10 (79) F10 key + case 109: return 0x79; + // VK_F11 (7A) F11 key + case 103: return 0x7A; + // VK_F12 (7B) F12 key + case 111: return 0x7B; + // VK_F13 (7C) F13 key + /*case NSF13FunctionKey: return 0x7C; + // VK_F14 (7D) F14 key + case NSF14FunctionKey: return 0x7D; + // VK_F15 (7E) F15 key + case NSF15FunctionKey: return 0x7E; + // VK_F16 (7F) F16 key + case NSF16FunctionKey: return 0x7F; + // VK_F17 (80H) F17 key + case NSF17FunctionKey: return 0x80; + // VK_F18 (81H) F18 key + case NSF18FunctionKey: return 0x81; + // VK_F19 (82H) F19 key + case NSF19FunctionKey: return 0x82; + // VK_F20 (83H) F20 key + case NSF20FunctionKey: return 0x83; + // VK_F21 (84H) F21 key + case NSF21FunctionKey: return 0x84; + // VK_F22 (85H) F22 key + case NSF22FunctionKey: return 0x85; + // VK_F23 (86H) F23 key + case NSF23FunctionKey: return 0x86; + // VK_F24 (87H) F24 key + case NSF24FunctionKey: return 0x87; + */ + // VK_NUMLOCK (90) NUM LOCK key + + // VK_SCROLL (91) SCROLL LOCK key + //case 0: return 0x91; + + // VK_LSHIFT (A0) Left SHIFT key + // VK_RSHIFT (A1) Right SHIFT key + // VK_LCONTROL (A2) Left CONTROL key + // VK_RCONTROL (A3) Right CONTROL key + // VK_LMENU (A4) Left MENU key + // VK_RMENU (A5) Right MENU key + // VK_BROWSER_BACK (A6) Windows 2000/XP: Browser Back key + // VK_BROWSER_FORWARD (A7) Windows 2000/XP: Browser Forward key + // VK_BROWSER_REFRESH (A8) Windows 2000/XP: Browser Refresh key + // VK_BROWSER_STOP (A9) Windows 2000/XP: Browser Stop key + // VK_BROWSER_SEARCH (AA) Windows 2000/XP: Browser Search key + // VK_BROWSER_FAVORITES (AB) Windows 2000/XP: Browser Favorites key + // VK_BROWSER_HOME (AC) Windows 2000/XP: Browser Start and Home key + // VK_VOLUME_MUTE (AD) Windows 2000/XP: Volume Mute key + // VK_VOLUME_DOWN (AE) Windows 2000/XP: Volume Down key + // VK_VOLUME_UP (AF) Windows 2000/XP: Volume Up key + // VK_MEDIA_NEXT_TRACK (B0) Windows 2000/XP: Next Track key + // VK_MEDIA_PREV_TRACK (B1) Windows 2000/XP: Previous Track key + // VK_MEDIA_STOP (B2) Windows 2000/XP: Stop Media key + // VK_MEDIA_PLAY_PAUSE (B3) Windows 2000/XP: Play/Pause Media key + // VK_LAUNCH_MAIL (B4) Windows 2000/XP: Start Mail key + // VK_LAUNCH_MEDIA_SELECT (B5) Windows 2000/XP: Select Media key + // VK_LAUNCH_APP1 (B6) Windows 2000/XP: Start Application 1 key + // VK_LAUNCH_APP2 (B7) Windows 2000/XP: Start Application 2 key + + // VK_OEM_1 (BA) Used for miscellaneous characters; it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the ';:' key + case 41: return 0xBA; + // VK_OEM_PLUS (BB) Windows 2000/XP: For any country/region, the '+' key + case 81: return 0xBB; + // VK_OEM_COMMA (BC) Windows 2000/XP: For any country/region, the ',' key + case 43: return 0xBC; + // VK_OEM_MINUS (BD) Windows 2000/XP: For any country/region, the '-' key + case 27: return 0xBD; + // VK_OEM_PERIOD (BE) Windows 2000/XP: For any country/region, the '.' key + case 47: return 0xBE; + // VK_OEM_2 (BF) Used for miscellaneous characters; it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the '/?' key + case 44: return 0xBF; + // VK_OEM_3 (C0) Used for miscellaneous characters; it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the '`~' key + case 50: return 0xC0; + // VK_OEM_4 (DB) Used for miscellaneous characters; it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the '[{' key + case 33: return 0xDB; + // VK_OEM_5 (DC) Used for miscellaneous characters; it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the '\|' key + case 42: return 0xDC; + // VK_OEM_6 (DD) Used for miscellaneous characters; it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the ']}' key + case 30: return 0xDD; + // VK_OEM_7 (DE) Used for miscellaneous characters; it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the 'single-quote/double-quote' key + case 39: return 0xDE; + + // VK_OEM_8 (DF) Used for miscellaneous characters; it can vary by keyboard. + // VK_OEM_102 (E2) Windows 2000/XP: Either the angle bracket key or the backslash key on the RT 102-key keyboard + // VK_PROCESSKEY (E5) Windows 95/98/Me, Windows NT 4.0, Windows 2000/XP: IME PROCESS key + // VK_PACKET (E7) Windows 2000/XP: Used to pass Unicode characters as if they were keystrokes. The VK_PACKET key is the low word of a 32-bit Virtual Key value used for non-keyboard input methods. For more information, see Remark in KEYBDINPUT,SendInput, WM_KEYDOWN, and WM_KEYUP + // VK_ATTN (F6) Attn key + // VK_CRSEL (F7) CrSel key + // VK_EXSEL (F8) ExSel key + // VK_EREOF (F9) Erase EOF key + // VK_PLAY (FA) Play key + // VK_ZOOM (FB) Zoom key + // VK_NONAME (FC) Reserved for future use + // VK_PA1 (FD) PA1 key + // VK_OEM_CLEAR (FE) Clear key + } + + return 0; +} + + void WebWidgetHost::SendKeyEvent(cef_key_type_t type, int key, int modifiers, bool sysChar, bool imeChar) { - // TODO(port): Implement this method as part of off-screen rendering support. - NOTIMPLEMENTED(); + + WebKeyboardEvent event; + switch ( type ) + { + case KT_KEYUP: + default: + event.type = WebInputEvent::KeyUp; + break; + case KT_KEYDOWN: + event.type = WebInputEvent::RawKeyDown; + break; + case KT_CHAR: + event.type = WebInputEvent::Char; + break; + } + event.timeStampSeconds = TickCount(); + + if ( modifiers & KEY_SHIFT ) + event.modifiers |= WebInputEvent::ShiftKey; + if ( modifiers & KEY_ALT ) + event.modifiers |= WebInputEvent::AltKey; + if ( modifiers & KEY_CTRL ) + event.modifiers |= WebInputEvent::ControlKey; + if ( modifiers & KEY_META ) + event.modifiers |= WebInputEvent::MetaKey; + + if ( event.type == WebInputEvent::Char ) + event.windowsKeyCode = key; + else + event.windowsKeyCode = windowsKeyCodeForKeyEventCode( key ); + + event.nativeKeyCode = key; + if (event.type == WebInputEvent::Char|| event.type == WebInputEvent::RawKeyDown ) + { + event.text[0] = key; + event.unmodifiedText[0] = key; + } + if (event.type != WebInputEvent::Char) + event.setKeyIdentifierFromWindowsKeyCode(); + + last_key_event_ = event; + + webwidget_->handleInputEvent(event); + } +WebMouseEvent::Button mouse_button_down_ = WebMouseEvent::ButtonNone; +int mouse_modifiers_ = 0; + void WebWidgetHost::SendMouseClickEvent(int x, int y, cef_mouse_button_type_t type, bool mouseUp, int clickCount) { - // TODO(port): Implement this method as part of off-screen rendering support. - NOTIMPLEMENTED(); + WebMouseEvent event; + switch(type) + { + case MBT_LEFT: + event.button = WebMouseEvent::ButtonLeft; + event.modifiers |= WebInputEvent::LeftButtonDown; + break; + case MBT_MIDDLE: + event.button = WebMouseEvent::ButtonMiddle; + event.modifiers |= WebInputEvent::MiddleButtonDown; + break; + case MBT_RIGHT: + event.button = WebMouseEvent::ButtonRight; + event.modifiers |= WebInputEvent::RightButtonDown; + break; + } + + if ( mouseUp ) + event.type = WebInputEvent::MouseUp; + else + event.type = WebInputEvent::MouseDown; + + event.clickCount = clickCount; + event.timeStampSeconds = TickCount(); + event.x = x; + event.y = y; + event.windowX = event.x; + event.windowY = event.y; + + if ( mouseUp ) + { + mouse_button_down_ = WebMouseEvent::ButtonNone; + mouse_modifiers_ &= ~event.modifiers; + } + else + { + mouse_modifiers_ |= event.modifiers; + mouse_button_down_ = event.button; + } + event.modifiers = mouse_modifiers_; + + webwidget_->handleInputEvent(event); } void WebWidgetHost::SendMouseMoveEvent(int x, int y, bool mouseLeave) { - // TODO(port): Implement this method as part of off-screen rendering support. - NOTIMPLEMENTED(); + + WebMouseEvent result; + result.timeStampSeconds = TickCount(); + result.type = WebInputEvent::MouseMove; + result.x = x; + result.y = y; + result.windowX = result.x; + result.windowY = result.y; + result.modifiers = mouse_modifiers_; + result.button = mouse_button_down_; + + webwidget_->handleInputEvent( result ); } void WebWidgetHost::SendMouseWheelEvent(int x, int y, int delta) { - // TODO(port): Implement this method as part of off-screen rendering support. - NOTIMPLEMENTED(); + WebMouseWheelEvent event; + + const int WHEEL_DELTA = 20; + + event.type = WebInputEvent::MouseWheel; + event.timeStampSeconds = TickCount(); + event.button = WebMouseEvent::ButtonNone; + static const float scrollbarPixelsPerLine = 100.0f / 3.0f; + event.deltaY = (float)delta*scrollbarPixelsPerLine; + event.wheelTicksY = (float)delta/WHEEL_DELTA; + //event.deltaX = (float)x*scrollbarPixelsPerLine; + //event.wheelTicksX = (float)x/WHEEL_DELTA; + event.hasPreciseScrollingDeltas = true; + event.x = x; + event.y = y; + event.windowX = event.x; + event.windowY = event.y; + + webwidget_->handleInputEvent(event); } void WebWidgetHost::SendFocusEvent(bool setFocus) { - // TODO(port): Implement this method as part of off-screen rendering support. - NOTIMPLEMENTED(); + SetFocus(setFocus); } void WebWidgetHost::SendCaptureLostEvent() { - // TODO(port): Implement this method as part of off-screen rendering support. - NOTIMPLEMENTED(); } void WebWidgetHost::EnsureTooltip() { - // TODO(port): Implement this method as part of tooltip support. } void WebWidgetHost::ResetTooltip() { - // TODO(port): Implement this method as part of tooltip support. } Index: libcef_dll/cpptoc/browser_cpptoc.cc =================================================================== --- libcef_dll/cpptoc/browser_cpptoc.cc (revision 465) +++ libcef_dll/cpptoc/browser_cpptoc.cc (working copy) @@ -551,17 +551,14 @@ return _retval; } -void CEF_CALLBACK browser_hide_popup(struct _cef_browser_t* self) { - // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING +void CEF_CALLBACK browser_hide_popup(struct _cef_browser_t* self) +{ + if(!self ) + return; - DCHECK(self); - if (!self) - return; - - // Execute - CefBrowserCppToC::Get(self)->HidePopup(); + CefRefPtr browserPtr = CefBrowserCppToC::Get(self); + browserPtr->HidePopup(); } - void CEF_CALLBACK browser_invalidate(struct _cef_browser_t* self, const cef_rect_t* dirtyRect) { // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING @@ -695,7 +692,337 @@ CefBrowserCppToC::Get(self)->SendCaptureLostEvent(); } +void CEF_CALLBACK browser_paint(struct _cef_browser_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + DCHECK(self); + if (!self) + return; + + // Execute + CefBrowserCppToC::Get(self)->Paint(); +} + +int CEF_CALLBACK browser_is_visually_non_empty(struct _cef_browser_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + bool _retval = CefBrowserCppToC::Get(self)->IsVisuallyNonEmpty(); + + // Return type: bool + return _retval; +} + +void CEF_CALLBACK browser_set_show_scroll_bars(struct _cef_browser_t* self, + int bShow) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + + // Execute + CefBrowserCppToC::Get(self)->SetShowScrollBars( + bShow?true:false); +} + +void CEF_CALLBACK browser_horizontal_scroll_bar_size( + struct _cef_browser_t* self, int* x, int* y, int* wide, int* tall) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: x; type: simple_byref + DCHECK(x); + if (!x) + return; + // Verify param: y; type: simple_byref + DCHECK(y); + if (!y) + return; + // Verify param: wide; type: simple_byref + DCHECK(wide); + if (!wide) + return; + // Verify param: tall; type: simple_byref + DCHECK(tall); + if (!tall) + return; + + // Translate param: x; type: simple_byref + int xVal = x?*x:0; + // Translate param: y; type: simple_byref + int yVal = y?*y:0; + // Translate param: wide; type: simple_byref + int wideVal = wide?*wide:0; + // Translate param: tall; type: simple_byref + int tallVal = tall?*tall:0; + + // Execute + CefBrowserCppToC::Get(self)->HorizontalScrollBarSize( + xVal, + yVal, + wideVal, + tallVal); + + // Restore param: x; type: simple_byref + if (x) + *x = xVal; + // Restore param: y; type: simple_byref + if (y) + *y = yVal; + // Restore param: wide; type: simple_byref + if (wide) + *wide = wideVal; + // Restore param: tall; type: simple_byref + if (tall) + *tall = tallVal; +} + +void CEF_CALLBACK browser_vertical_scroll_bar_size(struct _cef_browser_t* self, + int* x, int* y, int* wide, int* tall) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: x; type: simple_byref + DCHECK(x); + if (!x) + return; + // Verify param: y; type: simple_byref + DCHECK(y); + if (!y) + return; + // Verify param: wide; type: simple_byref + DCHECK(wide); + if (!wide) + return; + // Verify param: tall; type: simple_byref + DCHECK(tall); + if (!tall) + return; + + // Translate param: x; type: simple_byref + int xVal = x?*x:0; + // Translate param: y; type: simple_byref + int yVal = y?*y:0; + // Translate param: wide; type: simple_byref + int wideVal = wide?*wide:0; + // Translate param: tall; type: simple_byref + int tallVal = tall?*tall:0; + + // Execute + CefBrowserCppToC::Get(self)->VerticalScrollBarSize( + xVal, + yVal, + wideVal, + tallVal); + + // Restore param: x; type: simple_byref + if (x) + *x = xVal; + // Restore param: y; type: simple_byref + if (y) + *y = yVal; + // Restore param: wide; type: simple_byref + if (wide) + *wide = wideVal; + // Restore param: tall; type: simple_byref + if (tall) + *tall = tallVal; +} + +int CEF_CALLBACK browser_horizontal_scroll(struct _cef_browser_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + int _retval = CefBrowserCppToC::Get(self)->HorizontalScroll(); + + // Return type: simple + return _retval; +} + +int CEF_CALLBACK browser_vertical_scroll(struct _cef_browser_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + int _retval = CefBrowserCppToC::Get(self)->VerticalScroll(); + + // Return type: simple + return _retval; +} + +int CEF_CALLBACK browser_horizontal_scroll_max(struct _cef_browser_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + int _retval = CefBrowserCppToC::Get(self)->HorizontalScrollMax(); + + // Return type: simple + return _retval; +} + +int CEF_CALLBACK browser_vertical_scroll_max(struct _cef_browser_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + int _retval = CefBrowserCppToC::Get(self)->VerticalScrollMax(); + + // Return type: simple + return _retval; +} + +int CEF_CALLBACK browser_is_horizontal_scroll_bar_visible( + struct _cef_browser_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + bool _retval = CefBrowserCppToC::Get(self)->IsHorizontalScrollBarVisible(); + + // Return type: bool + return _retval; +} + +int CEF_CALLBACK browser_is_veritcal_scroll_bar_visible( + struct _cef_browser_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + bool _retval = CefBrowserCppToC::Get(self)->IsVeritcalScrollBarVisible(); + + // Return type: bool + return _retval; +} + +void CEF_CALLBACK browser_set_horizontal_scroll(struct _cef_browser_t* self, + int scroll) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + + // Execute + CefBrowserCppToC::Get(self)->SetHorizontalScroll( + scroll); +} + +void CEF_CALLBACK browser_set_vertical_scroll(struct _cef_browser_t* self, + int scroll) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + + // Execute + CefBrowserCppToC::Get(self)->SetVerticalScroll( + scroll); +} + +void CEF_CALLBACK browser_set_user_agent(struct _cef_browser_t* self, + const cef_string_t* pchUserAgent) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: pchUserAgent; type: string_byref_const + DCHECK(pchUserAgent); + if (!pchUserAgent) + return; + + // Execute + CefBrowserCppToC::Get(self)->SetUserAgent( + CefString(pchUserAgent)); +} + +cef_string_userfree_t CEF_CALLBACK browser_get_link_at_position( + struct _cef_browser_t* self, int x, int y) +{ + DCHECK(self); + if (!self) + return 0; + + // Execute + CefString str = CefBrowserCppToC::Get(self)->GetLinkAtPosition( x, y ); + return str.DetachToUserFree(); +} +int CEF_CALLBACK browser_zoom_to_element_at(struct _cef_browser_t* self, int x, + int y, int max_width, int max_height, int min_block_width, + int min_block_height, cef_rect_t* initialRect, cef_rect_t* finalRect) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + // Verify param: initialRect; type: simple_byref + DCHECK(initialRect); + if (!initialRect) + return 0; + // Verify param: finalRect; type: simple_byref + DCHECK(finalRect); + if (!finalRect) + return 0; + + // Translate param: initialRect; type: simple_byref + CefRect initialRectVal = initialRect?*initialRect:CefRect(); + // Translate param: finalRect; type: simple_byref + CefRect finalRectVal = finalRect?*finalRect:CefRect(); + + // Execute + int _retval = CefBrowserCppToC::Get(self)->zoomToElementAt( + x, + y, + max_width, + max_height, + min_block_width, + min_block_height, + initialRectVal, + finalRectVal); + + // Restore param: initialRect; type: simple_byref + if (initialRect) + *initialRect = initialRectVal; + // Restore param: finalRect; type: simple_byref + if (finalRect) + *finalRect = finalRectVal; + + // Return type: simple + return _retval; +} + + // CONSTRUCTOR - Do not edit by hand. CefBrowserCppToC::CefBrowserCppToC(CefBrowser* cls) @@ -740,6 +1067,25 @@ struct_.struct_.send_mouse_wheel_event = browser_send_mouse_wheel_event; struct_.struct_.send_focus_event = browser_send_focus_event; struct_.struct_.send_capture_lost_event = browser_send_capture_lost_event; + struct_.struct_.paint = browser_paint; + struct_.struct_.is_visually_non_empty = browser_is_visually_non_empty; + struct_.struct_.set_show_scroll_bars = browser_set_show_scroll_bars; + struct_.struct_.horizontal_scroll_bar_size = + browser_horizontal_scroll_bar_size; + struct_.struct_.vertical_scroll_bar_size = browser_vertical_scroll_bar_size; + struct_.struct_.horizontal_scroll = browser_horizontal_scroll; + struct_.struct_.vertical_scroll = browser_vertical_scroll; + struct_.struct_.horizontal_scroll_max = browser_horizontal_scroll_max; + struct_.struct_.vertical_scroll_max = browser_vertical_scroll_max; + struct_.struct_.is_horizontal_scroll_bar_visible = + browser_is_horizontal_scroll_bar_visible; + struct_.struct_.is_veritcal_scroll_bar_visible = + browser_is_veritcal_scroll_bar_visible; + struct_.struct_.set_horizontal_scroll = browser_set_horizontal_scroll; + struct_.struct_.set_vertical_scroll = browser_set_vertical_scroll; + struct_.struct_.set_user_agent = browser_set_user_agent; + struct_.struct_.get_link_at_position = browser_get_link_at_position; + struct_.struct_.zoom_to_element_at = browser_zoom_to_element_at; } #ifndef NDEBUG Index: libcef_dll/cpptoc/life_span_handler_cpptoc.cc =================================================================== --- libcef_dll/cpptoc/life_span_handler_cpptoc.cc (revision 465) +++ libcef_dll/cpptoc/life_span_handler_cpptoc.cc (working copy) @@ -171,7 +171,88 @@ CefBrowserCToCpp::Wrap(browser)); } +int CEF_CALLBACK life_span_handler_on_new_tab( + struct _cef_life_span_handler_t* self, cef_browser_t* parentBrowser, + const struct _cef_popup_features_t* popupFeatures, + cef_window_info_t* windowInfo, const cef_string_t* url, int bForeground, + cef_client_t** client, struct _cef_browser_settings_t* settings) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + DCHECK(self); + if (!self) + return 0; + // Verify param: parentBrowser; type: refptr_diff + DCHECK(parentBrowser); + if (!parentBrowser) + return 0; + // Verify param: popupFeatures; type: struct_byref_const + DCHECK(popupFeatures); + if (!popupFeatures) + return 0; + // Verify param: windowInfo; type: struct_byref + DCHECK(windowInfo); + if (!windowInfo) + return 0; + // Verify param: client; type: refptr_same_byref + DCHECK(client); + if (!client) + return 0; + // Verify param: settings; type: struct_byref + DCHECK(settings); + if (!settings) + return 0; + // Unverified params: url + + // Translate param: popupFeatures; type: struct_byref_const + CefPopupFeatures popupFeaturesObj; + if (popupFeatures) + popupFeaturesObj.Set(*popupFeatures, false); + // Translate param: windowInfo; type: struct_byref + CefWindowInfo windowInfoObj; + if (windowInfo) + windowInfoObj.AttachTo(*windowInfo); + // Translate param: client; type: refptr_same_byref + CefRefPtr clientPtr; + if (client && *client) + clientPtr = CefClientCppToC::Unwrap(*client); + CefClient* clientOrig = clientPtr.get(); + // Translate param: settings; type: struct_byref + CefBrowserSettings settingsObj; + if (settings) + settingsObj.AttachTo(*settings); + + // Execute + bool _retval = CefLifeSpanHandlerCppToC::Get(self)->OnNewTab( + CefBrowserCToCpp::Wrap(parentBrowser), + popupFeaturesObj, + windowInfoObj, + CefString(url), + bForeground?true:false, + clientPtr, + settingsObj); + + // Restore param: windowInfo; type: struct_byref + if (windowInfo) + windowInfoObj.DetachTo(*windowInfo); + // Restore param: client; type: refptr_same_byref + if (client) { + if (clientPtr.get()) { + if (clientPtr.get() != clientOrig) { + *client = CefClientCppToC::Wrap(clientPtr); + } + } else { + *client = NULL; + } + } + // Restore param: settings; type: struct_byref + if (settings) + settingsObj.DetachTo(*settings); + + // Return type: bool + return _retval; +} + + // CONSTRUCTOR - Do not edit by hand. CefLifeSpanHandlerCppToC::CefLifeSpanHandlerCppToC(CefLifeSpanHandler* cls) @@ -182,6 +263,7 @@ struct_.struct_.run_modal = life_span_handler_run_modal; struct_.struct_.do_close = life_span_handler_do_close; struct_.struct_.on_before_close = life_span_handler_on_before_close; + struct_.struct_.on_new_tab = life_span_handler_on_new_tab; } #ifndef NDEBUG Index: libcef_dll/cpptoc/load_handler_cpptoc.cc =================================================================== --- libcef_dll/cpptoc/load_handler_cpptoc.cc (revision 465) +++ libcef_dll/cpptoc/load_handler_cpptoc.cc (working copy) @@ -13,6 +13,7 @@ #include "libcef_dll/cpptoc/load_handler_cpptoc.h" #include "libcef_dll/ctocpp/browser_ctocpp.h" #include "libcef_dll/ctocpp/frame_ctocpp.h" +#include "libcef_dll/ctocpp/request_ctocpp.h" // MEMBER FUNCTIONS - Body may be edited by hand. @@ -40,7 +41,8 @@ } void CEF_CALLBACK load_handler_on_load_end(struct _cef_load_handler_t* self, - cef_browser_t* browser, cef_frame_t* frame, int httpStatusCode) { + cef_browser_t* browser, cef_frame_t* frame, int httpStatusCode, + struct _cef_request_t* req) { // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING DCHECK(self); @@ -54,12 +56,17 @@ DCHECK(frame); if (!frame) return; + // Verify param: req; type: refptr_diff + DCHECK(req); + if (!req) + return; // Execute CefLoadHandlerCppToC::Get(self)->OnLoadEnd( CefBrowserCToCpp::Wrap(browser), CefFrameCToCpp::Wrap(frame), - httpStatusCode); + httpStatusCode, + CefRequestCToCpp::Wrap(req)); } int CEF_CALLBACK load_handler_on_load_error(struct _cef_load_handler_t* self, Index: libcef_dll/cpptoc/load_handler_cpptoc.h =================================================================== --- libcef_dll/cpptoc/load_handler_cpptoc.h (revision 465) +++ libcef_dll/cpptoc/load_handler_cpptoc.h (working copy) @@ -24,6 +24,8 @@ #include "include/capi/cef_browser_capi.h" #include "include/cef_frame.h" #include "include/capi/cef_frame_capi.h" +#include "include/cef_request.h" +#include "include/capi/cef_request_capi.h" #include "libcef_dll/cpptoc/cpptoc.h" // Wrap a C++ class with a C structure. Index: libcef_dll/cpptoc/render_handler_cpptoc.cc =================================================================== --- libcef_dll/cpptoc/render_handler_cpptoc.cc (revision 465) +++ libcef_dll/cpptoc/render_handler_cpptoc.cc (working copy) @@ -228,7 +228,58 @@ cursor); } +int CEF_CALLBACK render_handler_on_set_cursor( + struct _cef_render_handler_t* self, cef_browser_t* browser, + enum cef_handler_cursortype_t type, const void* pchIconData, int iWide, + int iTall, int xHotSpot, int yHotSpot) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + DCHECK(self); + if (!self) + return 0; + // Verify param: browser; type: refptr_diff + DCHECK(browser); + if (!browser) + return 0; + + // Execute + bool _retval = CefRenderHandlerCppToC::Get(self)->OnSetCursor( + CefBrowserCToCpp::Wrap(browser), + type, + pchIconData, + iWide, + iTall, + xHotSpot, + yHotSpot); + + // Return type: bool + return _retval; +} + + +int CEF_CALLBACK render_handler_on_file_open_dialog( +struct _cef_render_handler_t* self, cef_browser_t* browser, + bool bMultiSelect, const cef_string_t*default_title, + const cef_string_t*default_file, void *pCallback ) { + + DCHECK(self); + if (!self) + return 0; + // Verify param: browser; type: refptr_diff + DCHECK(browser); + if (!browser) + return 0; + + // Execute + bool _retval = CefRenderHandlerCppToC::Get(self)->OnFileOpenDialog( + CefBrowserCToCpp::Wrap(browser), + bMultiSelect, default_title, default_file, (CefRenderHandler::CefWebFileChooserCallback *)pCallback ); + + // Return type: bool + return _retval; +} + + // CONSTRUCTOR - Do not edit by hand. CefRenderHandlerCppToC::CefRenderHandlerCppToC(CefRenderHandler* cls) @@ -241,6 +292,8 @@ struct_.struct_.on_popup_size = render_handler_on_popup_size; struct_.struct_.on_paint = render_handler_on_paint; struct_.struct_.on_cursor_change = render_handler_on_cursor_change; + struct_.struct_.on_set_cursor = render_handler_on_set_cursor; + struct_.struct_.on_file_open_dialog = render_handler_on_file_open_dialog; } #ifndef NDEBUG Index: libcef_dll/cpptoc/request_cpptoc.cc =================================================================== --- libcef_dll/cpptoc/request_cpptoc.cc (revision 465) +++ libcef_dll/cpptoc/request_cpptoc.cc (working copy) @@ -12,6 +12,7 @@ #include "libcef_dll/cpptoc/post_data_cpptoc.h" #include "libcef_dll/cpptoc/request_cpptoc.h" +#include "libcef_dll/cpptoc/security_details_cpptoc.h" #include "libcef_dll/transfer_util.h" @@ -266,7 +267,46 @@ CefString(url)); } +void CEF_CALLBACK request_set_security_details(struct _cef_request_t* self, + struct _cef_security_details_t* details) +{ + DCHECK(self); + if(!self) + return; + CefRefPtr securityDetailsPtr; + if(details) + securityDetailsPtr = CefSecurityDetailsCppToC::Unwrap(details); + + CefRequestCppToC::Get(self)->SetSecurityDetails( securityDetailsPtr ); +} +int CEF_CALLBACK request_bis_secure_request(struct _cef_request_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + bool _retval = CefRequestCppToC::Get(self)->BIsSecureRequest(); + + // Return type: bool + return _retval; +} + +struct _cef_security_details_t* CEF_CALLBACK request_security_details( + struct _cef_request_t* self) +{ + DCHECK(self); + if(!self) + return NULL; + + CefRefPtr securityDetailsPtr = CefRequestCppToC::Get(self)->SecurityDetails(); + + return CefSecurityDetailsCppToC::Wrap(securityDetailsPtr); + +} + // CONSTRUCTOR - Do not edit by hand. CefRequestCppToC::CefRequestCppToC(CefRequest* cls) @@ -286,6 +326,9 @@ request_get_first_party_for_cookies; struct_.struct_.set_first_party_for_cookies = request_set_first_party_for_cookies; + struct_.struct_.set_security_details = request_set_security_details; + struct_.struct_.bis_secure_request = request_bis_secure_request; + struct_.struct_.security_details = request_security_details; } #ifndef NDEBUG Index: libcef_dll/cpptoc/request_handler_cpptoc.cc =================================================================== --- libcef_dll/cpptoc/request_handler_cpptoc.cc (revision 465) +++ libcef_dll/cpptoc/request_handler_cpptoc.cc (working copy) @@ -25,7 +25,7 @@ int CEF_CALLBACK request_handler_on_before_browse( struct _cef_request_handler_t* self, cef_browser_t* browser, cef_frame_t* frame, cef_request_t* request, - enum cef_handler_navtype_t navType, int isRedirect) { + enum cef_handler_navtype_t navType, int isRedirect, int isNewTabRequest) { // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING DCHECK(self); @@ -50,7 +50,8 @@ CefFrameCToCpp::Wrap(frame), CefRequestCToCpp::Wrap(request), navType, - isRedirect?true:false); + isRedirect?true:false, + isNewTabRequest?true:false); // Return type: bool return _retval; Index: libcef_dll/cpptoc/security_details_cpptoc.cc =================================================================== --- libcef_dll/cpptoc/security_details_cpptoc.cc (revision 0) +++ libcef_dll/cpptoc/security_details_cpptoc.cc (working copy) @@ -0,0 +1,142 @@ +// Copyright (c) 2012 The Chromium Embedded Framework Authors. All rights +// reserved. Use of this source code is governed by a BSD-style license that +// can be found in the LICENSE file. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/security_details_cpptoc.h" + + +// MEMBER FUNCTIONS - Body may be edited by hand. + +int CEF_CALLBACK security_details_bis_secure( + struct _cef_security_details_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + bool _retval = CefSecurityDetailsCppToC::Get(self)->BIsSecure(); + + // Return type: bool + return _retval; +} + +int CEF_CALLBACK security_details_bhas_cert_error( + struct _cef_security_details_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + bool _retval = CefSecurityDetailsCppToC::Get(self)->BHasCertError(); + + // Return type: bool + return _retval; +} + +cef_string_userfree_t CEF_CALLBACK security_details_pch_cert_common_name( + struct _cef_security_details_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefString _retval = CefSecurityDetailsCppToC::Get(self)->PchCertCommonName(); + + // Return type: string + return _retval.DetachToUserFree(); +} + +cef_string_userfree_t CEF_CALLBACK security_details_pch_cert_issuer( + struct _cef_security_details_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefString _retval = CefSecurityDetailsCppToC::Get(self)->PchCertIssuer(); + + // Return type: string + return _retval.DetachToUserFree(); +} + +time_t CEF_CALLBACK security_details_tcert_expiry( + struct _cef_security_details_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + time_t _retval = CefSecurityDetailsCppToC::Get(self)->TCertExpiry(); + + // Return type: simple + return _retval; +} + +int CEF_CALLBACK security_details_ncert_bits( + struct _cef_security_details_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + int _retval = CefSecurityDetailsCppToC::Get(self)->NCertBits(); + + // Return type: simple + return _retval; +} + +int CEF_CALLBACK security_details_bis_evcert( + struct _cef_security_details_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + bool _retval = CefSecurityDetailsCppToC::Get(self)->BIsEVCert(); + + // Return type: bool + return _retval; +} + + +// CONSTRUCTOR - Do not edit by hand. + +CefSecurityDetailsCppToC::CefSecurityDetailsCppToC(CefSecurityDetails* cls) + : CefCppToC(cls) { + struct_.struct_.bis_secure = security_details_bis_secure; + struct_.struct_.bhas_cert_error = security_details_bhas_cert_error; + struct_.struct_.pch_cert_common_name = security_details_pch_cert_common_name; + struct_.struct_.pch_cert_issuer = security_details_pch_cert_issuer; + struct_.struct_.tcert_expiry = security_details_tcert_expiry; + struct_.struct_.ncert_bits = security_details_ncert_bits; + struct_.struct_.bis_evcert = security_details_bis_evcert; +} + +#ifndef NDEBUG +template<> long CefCppToC::DebugObjCt = 0; +#endif + Index: libcef_dll/cpptoc/security_details_cpptoc.h =================================================================== --- libcef_dll/cpptoc/security_details_cpptoc.h (revision 0) +++ libcef_dll/cpptoc/security_details_cpptoc.h (working copy) @@ -0,0 +1,38 @@ +// Copyright (c) 2012 The Chromium Embedded Framework Authors. All rights +// reserved. Use of this source code is governed by a BSD-style license that +// can be found in the LICENSE file. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CPPTOC_SECURITY_DETAILS_CPPTOC_H_ +#define CEF_LIBCEF_DLL_CPPTOC_SECURITY_DETAILS_CPPTOC_H_ +#pragma once + +#ifndef BUILDING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed DLL-side only") +#else // BUILDING_CEF_SHARED + +#include "include/cef_request.h" +#include "include/capi/cef_request_capi.h" +#include "libcef_dll/cpptoc/cpptoc.h" +#include "libcef_dll/cpptoc/security_details_cpptoc.h" + +// Wrap a C++ class with a C structure. +// This class may be instantiated and accessed DLL-side only. +class CefSecurityDetailsCppToC + : public CefCppToC { + public: + explicit CefSecurityDetailsCppToC(CefSecurityDetails* cls); + virtual ~CefSecurityDetailsCppToC() {} +}; + +#endif // BUILDING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CPPTOC_SECURITY_DETAILS_CPPTOC_H_ + Index: libcef_dll/ctocpp/browser_ctocpp.cc =================================================================== --- libcef_dll/ctocpp/browser_ctocpp.cc (revision 465) +++ libcef_dll/ctocpp/browser_ctocpp.cc (working copy) @@ -307,11 +307,11 @@ } void CefBrowserCToCpp::Find(int identifier, const CefString& searchText, - bool forward, bool matchCase, bool findNext) { - if (CEF_MEMBER_MISSING(struct_, find)) + bool forward, bool matchCase, bool findNext) +{ + if(CEF_MEMBER_MISSING(struct_, find)) return; - // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING // Verify param: searchText; type: string_byref_const DCHECK(!searchText.empty()); @@ -326,7 +326,6 @@ matchCase, findNext); } - void CefBrowserCToCpp::StopFinding(bool clearSelection) { if (CEF_MEMBER_MISSING(struct_, stop_finding)) return; @@ -570,7 +569,218 @@ struct_->send_capture_lost_event(struct_); } +void CefBrowserCToCpp::Paint() { + if (CEF_MEMBER_MISSING(struct_, paint)) + return; + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + struct_->paint(struct_); +} + +bool CefBrowserCToCpp::IsVisuallyNonEmpty() { + if (CEF_MEMBER_MISSING(struct_, is_visually_non_empty)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->is_visually_non_empty(struct_); + + // Return type: bool + return _retval?true:false; +} + +void CefBrowserCToCpp::SetShowScrollBars(bool bShow) { + if (CEF_MEMBER_MISSING(struct_, set_show_scroll_bars)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + struct_->set_show_scroll_bars(struct_, + bShow); +} + +void CefBrowserCToCpp::HorizontalScrollBarSize(int& x, int& y, int& wide, + int& tall) { + if (CEF_MEMBER_MISSING(struct_, horizontal_scroll_bar_size)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + struct_->horizontal_scroll_bar_size(struct_, + &x, + &y, + &wide, + &tall); +} + +void CefBrowserCToCpp::VerticalScrollBarSize(int& x, int& y, int& wide, + int& tall) { + if (CEF_MEMBER_MISSING(struct_, vertical_scroll_bar_size)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + struct_->vertical_scroll_bar_size(struct_, + &x, + &y, + &wide, + &tall); +} + +int CefBrowserCToCpp::HorizontalScroll() { + if (CEF_MEMBER_MISSING(struct_, horizontal_scroll)) + return 0; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->horizontal_scroll(struct_); + + // Return type: simple + return _retval; +} + +int CefBrowserCToCpp::VerticalScroll() { + if (CEF_MEMBER_MISSING(struct_, vertical_scroll)) + return 0; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->vertical_scroll(struct_); + + // Return type: simple + return _retval; +} + +int CefBrowserCToCpp::HorizontalScrollMax() { + if (CEF_MEMBER_MISSING(struct_, horizontal_scroll_max)) + return 0; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->horizontal_scroll_max(struct_); + + // Return type: simple + return _retval; +} + +int CefBrowserCToCpp::VerticalScrollMax() { + if (CEF_MEMBER_MISSING(struct_, vertical_scroll_max)) + return 0; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->vertical_scroll_max(struct_); + + // Return type: simple + return _retval; +} + +bool CefBrowserCToCpp::IsHorizontalScrollBarVisible() { + if (CEF_MEMBER_MISSING(struct_, is_horizontal_scroll_bar_visible)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->is_horizontal_scroll_bar_visible(struct_); + + // Return type: bool + return _retval?true:false; +} + +bool CefBrowserCToCpp::IsVeritcalScrollBarVisible() { + if (CEF_MEMBER_MISSING(struct_, is_veritcal_scroll_bar_visible)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->is_veritcal_scroll_bar_visible(struct_); + + // Return type: bool + return _retval?true:false; +} + +void CefBrowserCToCpp::SetHorizontalScroll(int scroll) { + if (CEF_MEMBER_MISSING(struct_, set_horizontal_scroll)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + struct_->set_horizontal_scroll(struct_, + scroll); +} + +void CefBrowserCToCpp::SetVerticalScroll(int scroll) { + if (CEF_MEMBER_MISSING(struct_, set_vertical_scroll)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + struct_->set_vertical_scroll(struct_, + scroll); +} + +void CefBrowserCToCpp::SetUserAgent(const CefString& pchUserAgent) { + if (CEF_MEMBER_MISSING(struct_, set_user_agent)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: pchUserAgent; type: string_byref_const + DCHECK(!pchUserAgent.empty()); + if (pchUserAgent.empty()) + return; + + // Execute + struct_->set_user_agent(struct_, + pchUserAgent.GetStruct()); +} + +const CefString CefBrowserCToCpp::GetLinkAtPosition(int x, int y) +{ + if (CEF_MEMBER_MISSING(struct_, get_link_at_position)) + return CefString(); + + CefString str = struct_->get_link_at_position( struct_, x, y ); + return str; +} +int CefBrowserCToCpp::zoomToElementAt(int x, int y, int max_width, + int max_height, int min_block_width, int min_block_height, + CefRect& initialRect, CefRect& finalRect) { + if (CEF_MEMBER_MISSING(struct_, zoom_to_element_at)) + return 0; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->zoom_to_element_at(struct_, + x, + y, + max_width, + max_height, + min_block_width, + min_block_height, + &initialRect, + &finalRect); + + // Return type: simple + return _retval; +} + + #ifndef NDEBUG template<> long CefCToCpp::DebugObjCt = 0; Index: libcef_dll/ctocpp/browser_ctocpp.h =================================================================== --- libcef_dll/ctocpp/browser_ctocpp.h (revision 465) +++ libcef_dll/ctocpp/browser_ctocpp.h (working copy) @@ -80,6 +80,26 @@ virtual void SendMouseWheelEvent(int x, int y, int delta) OVERRIDE; virtual void SendFocusEvent(bool setFocus) OVERRIDE; virtual void SendCaptureLostEvent() OVERRIDE; + virtual void Paint() OVERRIDE; + virtual bool IsVisuallyNonEmpty() OVERRIDE; + virtual void SetShowScrollBars(bool bShow) OVERRIDE; + virtual void HorizontalScrollBarSize(int& x, int& y, int& wide, + int& tall) OVERRIDE; + virtual void VerticalScrollBarSize(int& x, int& y, int& wide, + int& tall) OVERRIDE; + virtual int HorizontalScroll() OVERRIDE; + virtual int VerticalScroll() OVERRIDE; + virtual int HorizontalScrollMax() OVERRIDE; + virtual int VerticalScrollMax() OVERRIDE; + virtual bool IsHorizontalScrollBarVisible() OVERRIDE; + virtual bool IsVeritcalScrollBarVisible() OVERRIDE; + virtual void SetHorizontalScroll(int scroll) OVERRIDE; + virtual void SetVerticalScroll(int scroll) OVERRIDE; + virtual void SetUserAgent(const CefString& pchUserAgent) OVERRIDE; + virtual const CefString GetLinkAtPosition(int x, int y) OVERRIDE; + virtual int zoomToElementAt(int x, int y, int max_width, int max_height, + int min_block_width, int min_block_height, CefRect& initialRect, + CefRect& finalRect) OVERRIDE; }; #endif // USING_CEF_SHARED Index: libcef_dll/ctocpp/life_span_handler_ctocpp.cc =================================================================== --- libcef_dll/ctocpp/life_span_handler_ctocpp.cc (revision 465) +++ libcef_dll/ctocpp/life_span_handler_ctocpp.cc (working copy) @@ -130,7 +130,51 @@ CefBrowserCppToC::Wrap(browser)); } +bool CefLifeSpanHandlerCToCpp::OnNewTab(CefRefPtr parentBrowser, + const CefPopupFeatures& popupFeatures, CefWindowInfo& windowInfo, + const CefString& url, bool bForeground, CefRefPtr& client, + CefBrowserSettings& settings) { + if (CEF_MEMBER_MISSING(struct_, on_new_tab)) + return false; + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: parentBrowser; type: refptr_diff + DCHECK(parentBrowser.get()); + if (!parentBrowser.get()) + return false; + // Unverified params: url + + // Translate param: client; type: refptr_same_byref + cef_client_t* clientStruct = NULL; + if (client.get()) + clientStruct = CefClientCToCpp::Unwrap(client); + cef_client_t* clientOrig = clientStruct; + + // Execute + int _retval = struct_->on_new_tab(struct_, + CefBrowserCppToC::Wrap(parentBrowser), + &popupFeatures, + &windowInfo, + url.GetStruct(), + bForeground, + &clientStruct, + &settings); + + // Restore param:client; type: refptr_same_byref + if (clientStruct) { + if (clientStruct != clientOrig) { + client = CefClientCToCpp::Wrap(clientStruct); + } + } else { + client = NULL; + } + + // Return type: bool + return _retval?true:false; +} + + #ifndef NDEBUG template<> long CefCToCpp::DebugObjCt = 0; Index: libcef_dll/ctocpp/life_span_handler_ctocpp.h =================================================================== --- libcef_dll/ctocpp/life_span_handler_ctocpp.h (revision 465) +++ libcef_dll/ctocpp/life_span_handler_ctocpp.h (working copy) @@ -46,6 +46,10 @@ virtual bool RunModal(CefRefPtr browser) OVERRIDE; virtual bool DoClose(CefRefPtr browser) OVERRIDE; virtual void OnBeforeClose(CefRefPtr browser) OVERRIDE; + virtual bool OnNewTab(CefRefPtr parentBrowser, + const CefPopupFeatures& popupFeatures, CefWindowInfo& windowInfo, + const CefString& url, bool bForeground, CefRefPtr& client, + CefBrowserSettings& settings) OVERRIDE; }; #endif // BUILDING_CEF_SHARED Index: libcef_dll/ctocpp/load_handler_ctocpp.cc =================================================================== --- libcef_dll/ctocpp/load_handler_ctocpp.cc (revision 465) +++ libcef_dll/ctocpp/load_handler_ctocpp.cc (working copy) @@ -12,6 +12,7 @@ #include "libcef_dll/cpptoc/browser_cpptoc.h" #include "libcef_dll/cpptoc/frame_cpptoc.h" +#include "libcef_dll/cpptoc/request_cpptoc.h" #include "libcef_dll/ctocpp/load_handler_ctocpp.h" @@ -40,7 +41,8 @@ } void CefLoadHandlerCToCpp::OnLoadEnd(CefRefPtr browser, - CefRefPtr frame, int httpStatusCode) { + CefRefPtr frame, int httpStatusCode, + CefRefPtr req) { if (CEF_MEMBER_MISSING(struct_, on_load_end)) return; @@ -54,12 +56,17 @@ DCHECK(frame.get()); if (!frame.get()) return; + // Verify param: req; type: refptr_diff + DCHECK(req.get()); + if (!req.get()) + return; // Execute struct_->on_load_end(struct_, CefBrowserCppToC::Wrap(browser), CefFrameCppToC::Wrap(frame), - httpStatusCode); + httpStatusCode, + CefRequestCppToC::Wrap(req)); } bool CefLoadHandlerCToCpp::OnLoadError(CefRefPtr browser, Index: libcef_dll/ctocpp/load_handler_ctocpp.h =================================================================== --- libcef_dll/ctocpp/load_handler_ctocpp.h (revision 465) +++ libcef_dll/ctocpp/load_handler_ctocpp.h (working copy) @@ -24,6 +24,8 @@ #include "include/capi/cef_browser_capi.h" #include "include/cef_frame.h" #include "include/capi/cef_frame_capi.h" +#include "include/cef_request.h" +#include "include/capi/cef_request_capi.h" #include "libcef_dll/ctocpp/ctocpp.h" // Wrap a C structure with a C++ class. @@ -41,7 +43,8 @@ virtual void OnLoadStart(CefRefPtr browser, CefRefPtr frame) OVERRIDE; virtual void OnLoadEnd(CefRefPtr browser, - CefRefPtr frame, int httpStatusCode) OVERRIDE; + CefRefPtr frame, int httpStatusCode, + CefRefPtr req) OVERRIDE; virtual bool OnLoadError(CefRefPtr browser, CefRefPtr frame, ErrorCode errorCode, const CefString& failedUrl, CefString& errorText) OVERRIDE; Index: libcef_dll/ctocpp/render_handler_ctocpp.cc =================================================================== --- libcef_dll/ctocpp/render_handler_ctocpp.cc (revision 465) +++ libcef_dll/ctocpp/render_handler_ctocpp.cc (working copy) @@ -174,7 +174,55 @@ cursor); } +bool CefRenderHandlerCToCpp::OnSetCursor(CefRefPtr browser, + const CursorType type, const void* pchIconData, int iWide, int iTall, + int xHotSpot, int yHotSpot) { + if (CEF_MEMBER_MISSING(struct_, on_set_cursor)) + return false; + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: browser; type: refptr_diff + DCHECK(browser.get()); + if (!browser.get()) + return false; + + // Execute + int _retval = struct_->on_set_cursor(struct_, + CefBrowserCppToC::Wrap(browser), + type, + pchIconData, + iWide, + iTall, + xHotSpot, + yHotSpot); + + // Return type: bool + return _retval?true:false; +} + +bool CefRenderHandlerCToCpp::OnFileOpenDialog( CefRefPtr browser, bool bMultiSelect, const CefString &default_title, const CefString &default_file, CefWebFileChooserCallback *pCallback ) +{ + if (CEF_MEMBER_MISSING(struct_, on_file_open_dialog)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: browser; type: refptr_diff + DCHECK(browser.get()); + if (!browser.get()) + return false; + + // Execute + int _retval = struct_->on_file_open_dialog(struct_, + CefBrowserCppToC::Wrap(browser), + bMultiSelect, default_title.GetStruct(), default_file.GetStruct(), pCallback ); + + // Return type: bool + return _retval?true:false; +} + + #ifndef NDEBUG template<> long CefCToCpp::DebugObjCt = 0; Index: libcef_dll/ctocpp/render_handler_ctocpp.h =================================================================== --- libcef_dll/ctocpp/render_handler_ctocpp.h (revision 465) +++ libcef_dll/ctocpp/render_handler_ctocpp.h (working copy) @@ -49,6 +49,10 @@ const RectList& dirtyRects, const void* buffer) OVERRIDE; virtual void OnCursorChange(CefRefPtr browser, CefCursorHandle cursor) OVERRIDE; + virtual bool OnSetCursor(CefRefPtr browser, const CursorType type, + const void* pchIconData, int iWide, int iTall, int xHotSpot, + int yHotSpot) OVERRIDE; + virtual bool OnFileOpenDialog( CefRefPtr browser, bool bMultiSelect, const CefString &default_title, const CefString &default_file, CefWebFileChooserCallback *pCallback ) OVERRIDE; }; #endif // BUILDING_CEF_SHARED Index: libcef_dll/ctocpp/request_ctocpp.cc =================================================================== --- libcef_dll/ctocpp/request_ctocpp.cc (revision 465) +++ libcef_dll/ctocpp/request_ctocpp.cc (working copy) @@ -12,6 +12,7 @@ #include "libcef_dll/ctocpp/post_data_ctocpp.h" #include "libcef_dll/ctocpp/request_ctocpp.h" +#include "libcef_dll/ctocpp/security_details_ctocpp.h" #include "libcef_dll/transfer_util.h" @@ -256,7 +257,36 @@ url.GetStruct()); } +void CefRequestCToCpp::SetSecurityDetails(CefRefPtr details) +{ + if(CEF_MEMBER_MISSING(struct_, set_security_details )) + return; + cef_security_details_t* securityDetailsStruct = NULL; + if(details.get()) + securityDetailsStruct = CefSecurityDetailsCToCpp::Unwrap(details); + + struct_->set_security_details( struct_, securityDetailsStruct ); +} +bool CefRequestCToCpp::BIsSecureRequest() +{ + if(CEF_MEMBER_MISSING(struct_, bis_secure_request )) + return false; + + return struct_->bis_secure_request( struct_ ) > 0 ? true : false; +} +CefRefPtr CefRequestCToCpp::SecurityDetails() +{ + if(CEF_MEMBER_MISSING(struct_, security_details)) + return NULL; + + cef_security_details_t* securityDetailsStruct = struct_->security_details(struct_); + if(securityDetailsStruct) + return CefSecurityDetailsCToCpp::Wrap(securityDetailsStruct); + return NULL; + +} + #ifndef NDEBUG template<> long CefCToCpp::DebugObjCt = 0; Index: libcef_dll/ctocpp/request_ctocpp.h =================================================================== --- libcef_dll/ctocpp/request_ctocpp.h (revision 465) +++ libcef_dll/ctocpp/request_ctocpp.h (working copy) @@ -46,6 +46,10 @@ virtual void SetFlags(RequestFlags flags) OVERRIDE; virtual CefString GetFirstPartyForCookies() OVERRIDE; virtual void SetFirstPartyForCookies(const CefString& url) OVERRIDE; + virtual void SetSecurityDetails( + CefRefPtr details) OVERRIDE; + virtual bool BIsSecureRequest() OVERRIDE; + virtual CefRefPtr SecurityDetails() OVERRIDE; }; #endif // USING_CEF_SHARED Index: libcef_dll/ctocpp/request_handler_ctocpp.cc =================================================================== --- libcef_dll/ctocpp/request_handler_ctocpp.cc (revision 465) +++ libcef_dll/ctocpp/request_handler_ctocpp.cc (working copy) @@ -24,7 +24,7 @@ bool CefRequestHandlerCToCpp::OnBeforeBrowse(CefRefPtr browser, CefRefPtr frame, CefRefPtr request, NavType navType, - bool isRedirect) { + bool isRedirect, bool isNewTabRequest) { if (CEF_MEMBER_MISSING(struct_, on_before_browse)) return false; @@ -49,7 +49,8 @@ CefFrameCppToC::Wrap(frame), CefRequestCppToC::Wrap(request), navType, - isRedirect); + isRedirect, + isNewTabRequest); // Return type: bool return _retval?true:false; Index: libcef_dll/ctocpp/request_handler_ctocpp.h =================================================================== --- libcef_dll/ctocpp/request_handler_ctocpp.h (revision 465) +++ libcef_dll/ctocpp/request_handler_ctocpp.h (working copy) @@ -40,7 +40,7 @@ // CefRequestHandler methods virtual bool OnBeforeBrowse(CefRefPtr browser, CefRefPtr frame, CefRefPtr request, - NavType navType, bool isRedirect) OVERRIDE; + NavType navType, bool isRedirect, bool isNewTabRequest) OVERRIDE; virtual bool OnBeforeResourceLoad(CefRefPtr browser, CefRefPtr request, CefString& redirectUrl, CefRefPtr& resourceStream, Index: libcef_dll/ctocpp/security_details_ctocpp.cc =================================================================== --- libcef_dll/ctocpp/security_details_ctocpp.cc (revision 0) +++ libcef_dll/ctocpp/security_details_ctocpp.cc (working copy) @@ -0,0 +1,118 @@ +// Copyright (c) 2012 The Chromium Embedded Framework Authors. All rights +// reserved. Use of this source code is governed by a BSD-style license that +// can be found in the LICENSE file. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/ctocpp/security_details_ctocpp.h" + + +// VIRTUAL METHODS - Body may be edited by hand. + +bool CefSecurityDetailsCToCpp::BIsSecure() { + if (CEF_MEMBER_MISSING(struct_, bis_secure)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->bis_secure(struct_); + + // Return type: bool + return _retval?true:false; +} + +bool CefSecurityDetailsCToCpp::BHasCertError() { + if (CEF_MEMBER_MISSING(struct_, bhas_cert_error)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->bhas_cert_error(struct_); + + // Return type: bool + return _retval?true:false; +} + +CefString CefSecurityDetailsCToCpp::PchCertCommonName() { + if (CEF_MEMBER_MISSING(struct_, pch_cert_common_name)) + return CefString(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_string_userfree_t _retval = struct_->pch_cert_common_name(struct_); + + // Return type: string + CefString _retvalStr; + _retvalStr.AttachToUserFree(_retval); + return _retvalStr; +} + +CefString CefSecurityDetailsCToCpp::PchCertIssuer() { + if (CEF_MEMBER_MISSING(struct_, pch_cert_issuer)) + return CefString(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_string_userfree_t _retval = struct_->pch_cert_issuer(struct_); + + // Return type: string + CefString _retvalStr; + _retvalStr.AttachToUserFree(_retval); + return _retvalStr; +} + +time_t CefSecurityDetailsCToCpp::TCertExpiry() { + if (CEF_MEMBER_MISSING(struct_, tcert_expiry)) + return 0; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + time_t _retval = struct_->tcert_expiry(struct_); + + // Return type: simple + return _retval; +} + +int CefSecurityDetailsCToCpp::NCertBits() { + if (CEF_MEMBER_MISSING(struct_, ncert_bits)) + return 0; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->ncert_bits(struct_); + + // Return type: simple + return _retval; +} + +bool CefSecurityDetailsCToCpp::BIsEVCert() { + if (CEF_MEMBER_MISSING(struct_, bis_evcert)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = struct_->bis_evcert(struct_); + + // Return type: bool + return _retval?true:false; +} + + +#ifndef NDEBUG +template<> long CefCToCpp::DebugObjCt = 0; +#endif + Index: libcef_dll/ctocpp/security_details_ctocpp.h =================================================================== --- libcef_dll/ctocpp/security_details_ctocpp.h (revision 0) +++ libcef_dll/ctocpp/security_details_ctocpp.h (working copy) @@ -0,0 +1,48 @@ +// Copyright (c) 2012 The Chromium Embedded Framework Authors. All rights +// reserved. Use of this source code is governed by a BSD-style license that +// can be found in the LICENSE file. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef CEF_LIBCEF_DLL_CTOCPP_SECURITY_DETAILS_CTOCPP_H_ +#define CEF_LIBCEF_DLL_CTOCPP_SECURITY_DETAILS_CTOCPP_H_ +#pragma once + +#ifndef USING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed wrapper-side only") +#else // USING_CEF_SHARED + +#include "include/cef_request.h" +#include "include/capi/cef_request_capi.h" +#include "libcef_dll/ctocpp/ctocpp.h" + +// Wrap a C structure with a C++ class. +// This class may be instantiated and accessed wrapper-side only. +class CefSecurityDetailsCToCpp + : public CefCToCpp { + public: + explicit CefSecurityDetailsCToCpp(cef_security_details_t* str) + : CefCToCpp(str) {} + virtual ~CefSecurityDetailsCToCpp() {} + + // CefSecurityDetails methods + virtual bool BIsSecure() OVERRIDE; + virtual bool BHasCertError() OVERRIDE; + virtual CefString PchCertCommonName() OVERRIDE; + virtual CefString PchCertIssuer() OVERRIDE; + virtual time_t TCertExpiry() OVERRIDE; + virtual int NCertBits() OVERRIDE; + virtual bool BIsEVCert() OVERRIDE; +}; + +#endif // USING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CTOCPP_SECURITY_DETAILS_CTOCPP_H_ + Index: libcef_dll/libcef_dll.cc =================================================================== --- libcef_dll/libcef_dll.cc (revision 465) +++ libcef_dll/libcef_dll.cc (working copy) @@ -37,6 +37,7 @@ #include "libcef_dll/cpptoc/request_cpptoc.h" #include "libcef_dll/cpptoc/response_cpptoc.h" #include "libcef_dll/cpptoc/scheme_handler_callback_cpptoc.h" +#include "libcef_dll/cpptoc/security_details_cpptoc.h" #include "libcef_dll/cpptoc/stream_reader_cpptoc.h" #include "libcef_dll/cpptoc/stream_writer_cpptoc.h" #include "libcef_dll/cpptoc/v8context_cpptoc.h" @@ -80,29 +81,28 @@ // GLOBAL FUNCTIONS - Body may be edited by hand. CEF_EXPORT int cef_initialize(const struct _cef_settings_t* settings, - struct _cef_app_t* application) { - // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + struct _cef_app_t* application, const cef_string_t* pchResourceDLL) +{ - // Verify param: settings; type: struct_byref_const - DCHECK(settings); - if (!settings) - return 0; - // Unverified params: application + // Verify param: settings; type: struct_byref_const + DCHECK(settings); + if (!settings) + return 0; + // Unverified params: application - // Translate param: settings; type: struct_byref_const - CefSettings settingsObj; - if (settings) - settingsObj.Set(*settings, false); + // Translate param: settings; type: struct_byref_const + CefSettings settingsObj; + if (settings) + settingsObj.Set(*settings, false); - // Execute - bool _retval = CefInitialize( - settingsObj, - CefAppCToCpp::Wrap(application)); + // Execute + bool _retval = CefInitialize( + settingsObj, + CefAppCToCpp::Wrap(application), pchResourceDLL); - // Return type: bool - return _retval; + // Return type: bool + return _retval; } - CEF_EXPORT void cef_shutdown() { // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING @@ -144,6 +144,7 @@ DCHECK_EQ(CefSchemeHandlerCToCpp::DebugObjCt, 0); DCHECK_EQ(CefSchemeHandlerCallbackCppToC::DebugObjCt, 0); DCHECK_EQ(CefSchemeHandlerFactoryCToCpp::DebugObjCt, 0); + DCHECK_EQ(CefSecurityDetailsCppToC::DebugObjCt, 0); DCHECK_EQ(CefStorageVisitorCToCpp::DebugObjCt, 0); DCHECK_EQ(CefStreamReaderCppToC::DebugObjCt, 0); DCHECK_EQ(CefStreamWriterCppToC::DebugObjCt, 0); Index: libcef_dll/wrapper/libcef_dll_wrapper.cc =================================================================== --- libcef_dll/wrapper/libcef_dll_wrapper.cc (revision 465) +++ libcef_dll/wrapper/libcef_dll_wrapper.cc (working copy) @@ -27,7 +27,6 @@ #include "include/cef_v8.h" #include "include/capi/cef_v8_capi.h" #include "include/cef_version.h" -#include "libcef_dll/cpptoc/app_cpptoc.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" @@ -68,6 +67,7 @@ #include "libcef_dll/ctocpp/request_ctocpp.h" #include "libcef_dll/ctocpp/response_ctocpp.h" #include "libcef_dll/ctocpp/scheme_handler_callback_ctocpp.h" +#include "libcef_dll/ctocpp/security_details_ctocpp.h" #include "libcef_dll/ctocpp/stream_reader_ctocpp.h" #include "libcef_dll/ctocpp/stream_writer_ctocpp.h" #include "libcef_dll/ctocpp/v8context_ctocpp.h" @@ -76,6 +76,7 @@ #include "libcef_dll/ctocpp/web_urlrequest_ctocpp.h" #include "libcef_dll/ctocpp/xml_reader_ctocpp.h" #include "libcef_dll/ctocpp/zip_reader_ctocpp.h" +#include "libcef_dll/cpptoc/app_cpptoc.h" // Define used to facilitate parsing. #define CEF_GLOBAL @@ -84,7 +85,7 @@ // GLOBAL METHODS - Body may be edited by hand. CEF_GLOBAL bool CefInitialize(const CefSettings& settings, - CefRefPtr application) { + CefRefPtr application, const CefString pchResourceDLL) { int build_revision = cef_build_revision(); if (build_revision != CEF_REVISION) { // The libcef build revision does not match the CEF API revision. @@ -92,19 +93,16 @@ return false; } - // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING - - // Unverified params: application - // Execute int _retval = cef_initialize( - &settings, - CefAppCppToC::Wrap(application)); + &settings, + CefAppCppToC::Wrap(application), pchResourceDLL.GetStruct() ); // Return type: bool return _retval?true:false; } + CEF_GLOBAL void CefShutdown() { // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING @@ -146,6 +144,7 @@ DCHECK_EQ(CefSchemeHandlerCallbackCToCpp::DebugObjCt, 0); DCHECK_EQ(CefSchemeHandlerCppToC::DebugObjCt, 0); DCHECK_EQ(CefSchemeHandlerFactoryCppToC::DebugObjCt, 0); + DCHECK_EQ(CefSecurityDetailsCToCpp::DebugObjCt, 0); DCHECK_EQ(CefStorageVisitorCppToC::DebugObjCt, 0); DCHECK_EQ(CefStreamReaderCToCpp::DebugObjCt, 0); DCHECK_EQ(CefStreamWriterCToCpp::DebugObjCt, 0); Index: make.bat =================================================================== --- make.bat (revision 0) +++ make.bat (working copy) @@ -0,0 +1,33 @@ +@rem Make all environment variable changes local to this batch file +@setlocal + +@rem Add VS 2010 to path +call "%VS100COMNTOOLS%..\..\vc\bin\vcvars32.bat" + +@rem Avoid conflicts with previously installed versions of Python +set pythonhome= + +@rem Disable frame pointer omission. This allows us to get xperf call stacks. +set cl=/Oy- + +@rem Build the project files +call cef_create_projects.bat + +@rem Optionally clean everything so we get a total rebuild. +@rem devenv cef.sln /clean "release|win32" /project libcef +@rem devenv cef.sln /clean "debug|win32" /project libcef +@rem devenv cef.sln /clean "release|win32" /project libcef_dll_wrapper +@rem devenv cef.sln /clean "debug|win32" /project libcef_dll_wrapper + +@rem Build everything +devenv cef.sln /build "release|win32" /project libcef +devenv cef.sln /build "debug|win32" /project libcef +devenv cef.sln /build "release|win32" /project libcef_dll_wrapper +devenv cef.sln /build "debug|win32" /project libcef_dll_wrapper + +@rem Revert the unchanged files that were checked out by cef_create_projects.bat +@rem p4 revert -a -c default + +@rem call sourceindex.bat + +@echo Now cd to ..\.. and run publish_cef_to_steam.py, once with '-d' and then once without Index: patch/patch_state.h =================================================================== --- patch/patch_state.h (revision 0) +++ patch/patch_state.h (working copy) @@ -0,0 +1,6 @@ +// This file is generated by the patch tool and should not be edited manually. +#ifndef _PATCH_STATE_H +#define _PATCH_STATE_H +// Patches have been applied to the Chromium/WebKit source base. +#define CEF_PATCHES_APPLIED 1 +#endif // _PATCH_STATE_H Index: tests/cefclient/cefclient_gtk.cpp =================================================================== --- tests/cefclient/cefclient_gtk.cpp (revision 465) +++ tests/cefclient/cefclient_gtk.cpp (working copy) @@ -335,7 +335,7 @@ AppGetSettings(settings, app); // Initialize CEF. - CefInitialize(settings, app); + CefInitialize(settings, app, ""); // Register the V8 extension handler. InitExtensionTest(); Index: tests/cefclient/cefclient_mac.mm =================================================================== --- tests/cefclient/cefclient_mac.mm (revision 465) +++ tests/cefclient/cefclient_mac.mm (working copy) @@ -558,7 +558,7 @@ AppGetSettings(settings, app); // Initialize CEF. - CefInitialize(settings, app); + CefInitialize(settings, app, ""); // Initialize tests. InitExtensionTest(); Index: tests/cefclient/cefclient_win.cpp =================================================================== --- tests/cefclient/cefclient_win.cpp (revision 465) +++ tests/cefclient/cefclient_win.cpp (working copy) @@ -73,7 +73,7 @@ AppGetSettings(settings, app); // Initialize CEF. - CefInitialize(settings, app); + CefInitialize(settings, app, ""); // Register the internal client plugin. InitPluginTest(); Index: tests/cefclient/client_handler.cpp =================================================================== --- tests/cefclient/client_handler.cpp (revision 465) +++ tests/cefclient/client_handler.cpp (working copy) @@ -80,7 +80,7 @@ void ClientHandler::OnLoadEnd(CefRefPtr browser, CefRefPtr frame, - int httpStatusCode) { + int httpStatusCode, CefRefPtr req) { REQUIRE_UI_THREAD(); if (m_BrowserHwnd == browser->GetWindowHandle() && frame->IsMain()) { Index: tests/cefclient/client_handler.h =================================================================== --- tests/cefclient/client_handler.h (revision 465) +++ tests/cefclient/client_handler.h (working copy) @@ -83,7 +83,7 @@ CefRefPtr frame) OVERRIDE; virtual void OnLoadEnd(CefRefPtr browser, CefRefPtr frame, - int httpStatusCode) OVERRIDE; + int httpStatusCode, CefRefPtr req ) OVERRIDE; virtual bool OnLoadError(CefRefPtr browser, CefRefPtr frame, ErrorCode errorCode, Index: tests/cefclient/client_popup_handler.cpp =================================================================== --- tests/cefclient/client_popup_handler.cpp (revision 465) +++ tests/cefclient/client_popup_handler.cpp (working copy) @@ -18,7 +18,7 @@ CefRefPtr frame, CefRefPtr request, NavType navType, - bool isRedirect) { + bool isRedirect, bool isNewTabRequest ) { REQUIRE_UI_THREAD(); // Load the request in the parent browser window. Index: tests/cefclient/client_popup_handler.h =================================================================== --- tests/cefclient/client_popup_handler.h (revision 465) +++ tests/cefclient/client_popup_handler.h (working copy) @@ -28,7 +28,7 @@ CefRefPtr frame, CefRefPtr request, NavType navType, - bool isRedirect) OVERRIDE; + bool isRedirect, bool isNewTabRequest ) OVERRIDE; protected: CefRefPtr m_ParentBrowser; Index: tests/cefclient/osrplugin.cpp =================================================================== --- tests/cefclient/osrplugin.cpp (revision 465) +++ tests/cefclient/osrplugin.cpp (working copy) @@ -135,7 +135,7 @@ virtual void OnLoadEnd(CefRefPtr browser, CefRefPtr frame, - int httpStatusCode) OVERRIDE { + int httpStatusCode, CefRefPtr req) OVERRIDE { REQUIRE_UI_THREAD(); if (!browser->IsPopup() && frame->IsMain()) { Index: tests/cefclient/uiplugin.cpp =================================================================== --- tests/cefclient/uiplugin.cpp (revision 465) +++ tests/cefclient/uiplugin.cpp (working copy) @@ -30,18 +30,23 @@ hWnd = NULL; hDC = NULL; hRC = NULL; +#endif } +#if defined(OS_WIN) HWND hWnd; HDC hDC; HGLRC hRC; +#endif }; +#if defined(OS_WIN) // Forward declarations of functions included in this code module: LRESULT CALLBACK PluginWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam); void EnableOpenGL(HWND hWnd, HDC * hDC, HGLRC * hRC); void DisableOpenGL(HWND hWnd, HDC hDC, HGLRC hRC); +#endif NPError NPP_NewImpl(NPMIMEType plugin_type, NPP instance, uint16 mode, int16 argc, char* argn[], char* argv[], @@ -59,10 +64,12 @@ ClientPlugin* plugin = reinterpret_cast(instance->pdata); if (plugin) { +#if defined(OS_WIN) if (plugin->hWnd) { DestroyWindow(plugin->hWnd); DisableOpenGL(plugin->hWnd, plugin->hDC, plugin->hRC); } +#endif delete plugin; g_rotationspeed = 0.0f; g_theta = 0.0f; @@ -78,6 +85,7 @@ if (window_info == NULL) return NPERR_GENERIC_ERROR; +#if defined(OS_WIN) ClientPlugin* plugin = reinterpret_cast(instance->pdata); HWND parent_hwnd = reinterpret_cast(window_info->window); @@ -118,7 +126,7 @@ UpdateWindow(plugin->hWnd); ShowWindow(plugin->hWnd, SW_SHOW); - +#endif return NPERR_NO_ERROR; } @@ -150,6 +158,7 @@ 0x10, 0x18, 0x18, 0x08, 0x10, 0x00, 0x00, 0x08}; +#if defined(OS_WIN) // Plugin window procedure. LRESULT CALLBACK PluginWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { @@ -224,7 +233,9 @@ return DefWindowProc(hWnd, message, wParam, lParam); } +#endif +#if defined(OS_WIN) // Enable OpenGL. void EnableOpenGL(HWND hWnd, HDC * hDC, HGLRC * hRC) { PIXELFORMATDESCRIPTOR pfd; Index: tests/unittests/content_filter_unittest.cc =================================================================== --- tests/unittests/content_filter_unittest.cc (revision 465) +++ tests/unittests/content_filter_unittest.cc (working copy) @@ -185,7 +185,7 @@ virtual void OnLoadEnd(CefRefPtr browser, CefRefPtr frame, - int httpStatusCode) OVERRIDE { + int httpStatusCode, CefRefPtr req) OVERRIDE { EXPECT_TRUE(CefCurrentlyOn(TID_UI)); if (frame->IsMain()) { Index: tests/unittests/dom_unittest.cc =================================================================== --- tests/unittests/dom_unittest.cc (revision 465) +++ tests/unittests/dom_unittest.cc (working copy) @@ -226,7 +226,7 @@ virtual void OnLoadEnd(CefRefPtr browser, CefRefPtr frame, - int httpStatusCode) OVERRIDE { + int httpStatusCode, CefRefPtr req ) OVERRIDE { if (frame->IsMain()) { // The page is done loading so visit the DOM. browser->GetMainFrame()->VisitDOM(visitor_.get()); Index: tests/unittests/navigation_unittest.cc =================================================================== --- tests/unittests/navigation_unittest.cc (revision 465) +++ tests/unittests/navigation_unittest.cc (working copy) @@ -96,7 +96,7 @@ CefRefPtr frame, CefRefPtr request, NavType navType, - bool isRedirect) OVERRIDE { + bool isRedirect, bool isNewTabRequest ) OVERRIDE { const NavListItem& item = kNavList[nav_]; got_before_browse_[nav_].yes(); @@ -129,7 +129,7 @@ virtual void OnLoadEnd(CefRefPtr browser, CefRefPtr frame, - int httpStatusCode) OVERRIDE { + int httpStatusCode, CefRefPtr req) OVERRIDE { if (browser->IsPopup() || !frame->IsMain()) return; @@ -225,7 +225,7 @@ CefRefPtr frame, CefRefPtr request, NavType navType, - bool isRedirect) OVERRIDE { + bool isRedirect, bool isNewTabRequest ) OVERRIDE { std::string url = request->GetURL(); std::string name = frame->GetName(); CefRefPtr parent = frame->GetParent(); @@ -255,7 +255,7 @@ virtual void OnLoadEnd(CefRefPtr browser, CefRefPtr frame, - int httpStatusCode) OVERRIDE { + int httpStatusCode,CefRefPtr req) OVERRIDE { std::string url = frame->GetURL(); CefRefPtr parent = frame->GetParent(); @@ -458,7 +458,7 @@ CefRefPtr frame, CefRefPtr request, NavType navType, - bool isRedirect) OVERRIDE { + bool isRedirect, bool isNewTabRequest ) OVERRIDE { // Should be called for each URL that is actually loaded. std::string url = request->GetURL(); @@ -529,7 +529,7 @@ virtual void OnLoadEnd(CefRefPtr browser, CefRefPtr frame, - int httpStatusCode) OVERRIDE { + int httpStatusCode, CefRefPtr req) OVERRIDE { // Should only be called for the final loaded URL. std::string url = frame->GetURL(); Index: tests/unittests/request_unittest.cc =================================================================== --- tests/unittests/request_unittest.cc (revision 465) +++ tests/unittests/request_unittest.cc (working copy) @@ -124,19 +124,19 @@ // CefPostData AddElement postData->AddElement(element1); postData->AddElement(element2); - ASSERT_EQ((size_t)2, postData->GetElementCount()); + ASSERT_EQ((unsigned long)2, postData->GetElementCount()); // CefPostData RemoveElement postData->RemoveElement(element1); - ASSERT_EQ((size_t)1, postData->GetElementCount()); + ASSERT_EQ((unsigned long)1, postData->GetElementCount()); // CefPostData RemoveElements postData->RemoveElements(); - ASSERT_EQ((size_t)0, postData->GetElementCount()); + ASSERT_EQ((unsigned long)0, postData->GetElementCount()); postData->AddElement(element1); postData->AddElement(element2); - ASSERT_EQ((size_t)2, postData->GetElementCount()); + ASSERT_EQ((unsigned long)2, postData->GetElementCount()); CefPostData::ElementVector elements; postData->GetElements(elements); CefPostData::ElementVector::const_iterator it = elements.begin(); @@ -234,8 +234,7 @@ virtual bool OnBeforeBrowse(CefRefPtr browser, CefRefPtr frame, CefRefPtr request, - NavType navType, - bool isRedirect) OVERRIDE { + NavType navType, bool isRedirect, bool isNewTabRequest ) OVERRIDE { g_RequestSendRecvTestHandlerHandleBeforeBrowseCalled = true; // Verify that the request is the same @@ -254,7 +253,6 @@ // Verify that the request is the same VerifyRequestEqual(request_, request, true); - DestroyTest(); // No results Index: tests/unittests/run_all_unittests.cc =================================================================== --- tests/unittests/run_all_unittests.cc (revision 465) +++ tests/unittests/run_all_unittests.cc (working copy) @@ -57,7 +57,7 @@ #endif // Initialize CEF. - CefInitialize(settings, NULL); + CefInitialize(settings, NULL, ""); // Create the test suite object. CefTestSuite test_suite(argc, argv); Index: tests/unittests/scheme_handler_unittest.cc =================================================================== --- tests/unittests/scheme_handler_unittest.cc (revision 465) +++ tests/unittests/scheme_handler_unittest.cc (working copy) @@ -92,7 +92,7 @@ CefRefPtr frame, CefRefPtr request, NavType navType, - bool isRedirect) OVERRIDE { + bool isRedirect, bool isNewTabRequest) OVERRIDE { std::string newUrl = request->GetURL(); if (!test_results_->exit_url.empty() && newUrl.find(test_results_->exit_url) != std::string::npos) { @@ -121,7 +121,7 @@ virtual void OnLoadEnd(CefRefPtr browser, CefRefPtr frame, - int httpStatusCode) OVERRIDE { + int httpStatusCode, CefRefPtr req) OVERRIDE { std::string url = frame->GetURL(); if (url == test_results_->url || test_results_->status_code != 200) { if (test_results_->sub_url.empty()) { Index: tests/unittests/storage_unittest.cc =================================================================== --- tests/unittests/storage_unittest.cc (revision 465) +++ tests/unittests/storage_unittest.cc (working copy) @@ -153,7 +153,7 @@ virtual void OnLoadEnd(CefRefPtr browser, CefRefPtr frame, - int httpStatusCode) OVERRIDE { + int httpStatusCode, CefRefPtr req) OVERRIDE { if (nav_ == 0) { // Verify read all. CefVisitStorage(type_, "", "", Index: tests/unittests/stream_unittest.cc =================================================================== --- tests/unittests/stream_unittest.cc (revision 465) +++ tests/unittests/stream_unittest.cc (working copy) @@ -5,6 +5,12 @@ #include "include/cef_stream.h" #include "testing/gtest/include/gtest/gtest.h" +int min( int a, int b ) +{ + return ( a < b ) ? a : b; +} + + static void VerifyStreamReadBehavior(CefRefPtr stream, const std::string& contents) { int contentSize = static_cast(contents.size()); @@ -26,7 +32,7 @@ char buff[10]; int res, read, offset = 0; do { - read = std::min(static_cast(sizeof(buff)), contentSize-offset); + read = min(sizeof(buff), contentSize-offset); res = stream->Read(buff, 1, read); ASSERT_EQ(read, res); ASSERT_TRUE(!memcmp(contentStr+offset, buff, res)); @@ -67,38 +73,39 @@ } TEST(StreamTest, ReadFile) { - const char* fileName = "StreamTest.VerifyReadFile.txt"; - CefString fileNameStr = "StreamTest.VerifyReadFile.txt"; - std::string contents = "This is my test\ncontents for the file"; + const char* fileName = "StreamTest.VerifyReadFile.txt"; + CefString fileNameStr = "StreamTest.VerifyReadFile.txt"; + std::string contents = "This is my test\ncontents for the file"; - // Create the file - FILE* f = NULL; + // Create the file + FILE* f = NULL; #ifdef _WIN32 - fopen_s(&f, fileName, "wb"); + fopen_s(&f, fileName, "wb"); #else - f = fopen(fileName, "wb"); + f = fopen(fileName, "wb"); #endif - ASSERT_TRUE(f != NULL); - ASSERT_EQ((size_t)1, fwrite(contents.c_str(), contents.size(), 1, f)); - fclose(f); + ASSERT_TRUE(f != NULL); + ASSERT_EQ((size_t)1, fwrite(contents.c_str(), contents.size(), 1, f)); + fclose(f); - // Test the stream - CefRefPtr stream( - CefStreamReader::CreateForFile(fileNameStr)); - ASSERT_TRUE(stream.get() != NULL); - VerifyStreamReadBehavior(stream, contents); + // Test the stream + CefRefPtr stream( + CefStreamReader::CreateForFile(fileNameStr)); + ASSERT_TRUE(stream.get() != NULL); + VerifyStreamReadBehavior(stream, contents); - // Release the file pointer - stream = NULL; + // Release the file pointer + stream = NULL; - // Delete the file + // Delete the file #ifdef _WIN32 - ASSERT_EQ(0, _unlink(fileName)); + ASSERT_EQ(0, _unlink(fileName)); #else - ASSERT_EQ(0, unlink(fileName)); + ASSERT_EQ(0, unlink(fileName)); #endif } + TEST(StreamTest, ReadData) { std::string contents = "This is my test\ncontents for the file"; @@ -112,47 +119,48 @@ } TEST(StreamTest, WriteFile) { - const char* fileName = "StreamTest.VerifyWriteFile.txt"; - CefString fileNameStr = "StreamTest.VerifyWriteFile.txt"; - std::string contents = "This is my test\ncontents for the file"; + const char* fileName = "StreamTest.VerifyWriteFile.txt"; + CefString fileNameStr = "StreamTest.VerifyWriteFile.txt"; + std::string contents = "This is my test\ncontents for the file"; - // Test the stream - CefRefPtr stream( - CefStreamWriter::CreateForFile(fileNameStr)); - ASSERT_TRUE(stream.get() != NULL); - VerifyStreamWriteBehavior(stream, contents); + // Test the stream + CefRefPtr stream( + CefStreamWriter::CreateForFile(fileNameStr)); + ASSERT_TRUE(stream.get() != NULL); + VerifyStreamWriteBehavior(stream, contents); - // Release the file pointer - stream = NULL; + // Release the file pointer + stream = NULL; - // Read the file that was written - FILE* f = NULL; - char* buff = new char[contents.size()]; + // Read the file that was written + FILE* f = NULL; + char* buff = new char[contents.size()]; #ifdef _WIN32 - fopen_s(&f, fileName, "rb"); + fopen_s(&f, fileName, "rb"); #else - f = fopen(fileName, "rb"); + f = fopen(fileName, "rb"); #endif - ASSERT_TRUE(f != NULL); - ASSERT_EQ((size_t)1, fread(buff, contents.size(), 1, f)); + ASSERT_TRUE(f != NULL); + ASSERT_EQ((size_t)1, fread(buff, contents.size(), 1, f)); - // Read past the end of the file - fgetc(f); - ASSERT_TRUE(feof(f)); - fclose(f); + // Read past the end of the file + fgetc(f); + ASSERT_TRUE(feof(f)); + fclose(f); - // Verify the file contents - ASSERT_TRUE(!memcmp(contents.c_str(), buff, contents.size())); - delete [] buff; + // Verify the file contents + ASSERT_TRUE(!memcmp(contents.c_str(), buff, contents.size())); + delete [] buff; - // Delete the file + // Delete the file #ifdef _WIN32 - ASSERT_EQ(0, _unlink(fileName)); + ASSERT_EQ(0, _unlink(fileName)); #else - ASSERT_EQ(0, unlink(fileName)); + ASSERT_EQ(0, unlink(fileName)); #endif } + bool g_ReadHandlerTesterDeleted = false; class ReadHandlerTester : public CefReadHandler { @@ -225,7 +233,7 @@ size_t read_size = sizeof(read_ptr); size_t read_n = 1; size_t read_res = stream->Read( - static_cast(const_cast(read_ptr)), read_size, read_n); + static_cast(const_cast(read_ptr)), read_size, read_n); ASSERT_TRUE(handler->read_called_); ASSERT_EQ((size_t)10, read_res); ASSERT_EQ(read_ptr, handler->read_ptr_); @@ -329,7 +337,7 @@ const char* write_ptr = "My data"; size_t write_size = sizeof(write_ptr); size_t write_n = 1; - size_t write_res = stream->Write(write_ptr, write_size, write_n); + size_t write_res = stream->Write((char *)write_ptr, write_size, write_n); ASSERT_TRUE(handler->write_called_); ASSERT_EQ((size_t)10, write_res); ASSERT_EQ(write_ptr, handler->write_ptr_); Index: tests/unittests/test_handler.h =================================================================== --- tests/unittests/test_handler.h (revision 465) +++ tests/unittests/test_handler.h (working copy) @@ -77,8 +77,15 @@ int loadFlags) OVERRIDE; CefRefPtr GetBrowser() { return browser_; } +#if defined(OS_WIN) CefWindowHandle GetBrowserHwnd() { return browser_hwnd_; } + +#endif + + +#if defined(OS_WIN) +#endif // Called by the test function to execute the test. This method blocks until // the test is complete. Do not reference the object after this method // returns. Index: tests/unittests/v8_unittest.cc =================================================================== --- tests/unittests/v8_unittest.cc (revision 465) +++ tests/unittests/v8_unittest.cc (working copy) @@ -278,7 +278,7 @@ virtual void OnLoadEnd(CefRefPtr browser, CefRefPtr frame, - int httpStatusCode) OVERRIDE { + int httpStatusCode,CefRefPtr req) OVERRIDE { if (!browser->IsPopup() && frame->IsMain()) DestroyTest(); } @@ -446,7 +446,7 @@ virtual void OnLoadEnd(CefRefPtr browser, CefRefPtr frame, - int httpStatusCode) OVERRIDE { + int httpStatusCode,CefRefPtr req) OVERRIDE { DestroyTest(); } @@ -669,7 +669,7 @@ virtual void OnLoadEnd(CefRefPtr browser, CefRefPtr frame, - int httpStatusCode) OVERRIDE { + int httpStatusCode,CefRefPtr req) OVERRIDE { } virtual void OnContextCreated(CefRefPtr browser, @@ -1326,7 +1326,7 @@ virtual void OnLoadEnd(CefRefPtr browser, CefRefPtr frame, - int httpStatusCode) OVERRIDE { + int httpStatusCode,CefRefPtr req) OVERRIDE { if (nav_ == 0) { // Navigate to the next page. frame->LoadURL("http://tests/run2.html"); @@ -1615,7 +1615,7 @@ virtual void OnLoadEnd(CefRefPtr browser, CefRefPtr frame, - int httpStatusCode) OVERRIDE { + int httpStatusCode,CefRefPtr req) OVERRIDE { got_load_end_.yes(); // Test 3: Execute the callback asynchronously without re-throwing the Index: tests/unittests/web_urlrequest_unittest.cc =================================================================== --- tests/unittests/web_urlrequest_unittest.cc (revision 465) +++ tests/unittests/web_urlrequest_unittest.cc (working copy) @@ -61,7 +61,7 @@ virtual void OnLoadEnd(CefRefPtr browser, CefRefPtr frame, - int httpStatusCode) { + int httpStatusCode,CefRefPtr req) { StartTest(); } Index: tools/cef_parser.py =================================================================== --- tools/cef_parser.py (revision 465) +++ tools/cef_parser.py (working copy) @@ -1,3 +1,5 @@ +#!/usr/bin/env python + # Copyright (c) 2011 The Chromium Embedded Framework Authors. All rights # reserved. Use of this source code is governed by a BSD-style license that # can be found in the LICENSE file. @@ -12,7 +14,6 @@ import textwrap import time - def notify(msg): """ Display a message. """ sys.stdout.write(' NOTE: '+msg+'\n') @@ -1496,6 +1497,8 @@ 'CefRect' : ['cef_rect_t', 'CefRect()'], 'CefThreadId' : ['cef_thread_id_t', 'TID_UI'], 'CefTime' : ['cef_time_t', 'CefTime()'], + 'unsigned short' : 'unsigned short', + 'char' : 'char', } if value in simpletypes.keys(): return { @@ -1511,6 +1514,7 @@ 'result_value' : value } + # check for CEF reference pointers p = re.compile('^CefRefPtr<(.*?)>$', re.DOTALL) list = p.findall(value) @@ -1528,6 +1532,34 @@ 'result_value' : get_capi_name(value, True) } + # check for IInputEventHTML + p = re.compile('^IInputEventHTML(.*?)$', re.DOTALL) + list = p.findall(value) + if len(list) == 1: + return { + 'result_type' : 'simple', + 'result_value' : value + } + + # check for IPaintHTML + p = re.compile('^IPaintHTML(.*?)$', re.DOTALL) + list = p.findall(value) + if len(list) == 1: + return { + 'result_type' : 'simple', + 'result_value' : value + } + + # check for cef_handler_cef_web_file_chooser_callback + p = re.compile('^cef_handler_cef_web_file_chooser_callback(.*?)$', re.DOTALL) + list = p.findall(value) + if len(list) == 1: + return { + 'result_type' : 'simple', + 'result_value' : value + } + + return None def __repr__(self): @@ -1753,6 +1785,8 @@ format = 'single' if self.is_result_simple(): result += self.get_result_simple_type() + elif self.result_type == 'pointer': + result += self.result_value elif self.is_result_refptr(): result += self.get_result_refptr_type(defined_structs) elif self.is_result_struct(): Index: tools/patch_util.py =================================================================== --- tools/patch_util.py (revision 465) +++ tools/patch_util.py (working copy) @@ -388,7 +388,8 @@ shutil.move(filename, backupname) if patch_hunks(backupname, filename, self.hunks[fileno]): warning("successfully patched %s" % filename) - unlink(backupname) + # VALVE BUILD - remove the unlink to make p4 happy + #unlink(backupname) else: warning("error patching file %s" % filename) shutil.copy(filename, filename+".invalid") Index: tools/patcher.py =================================================================== --- tools/patcher.py (revision 465) +++ tools/patcher.py (working copy) @@ -1,3 +1,5 @@ +#!/usr/bin/env python + # Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights # reserved. Use of this source code is governed by a BSD-style license that # can be found in the LICENSE file. Index: tools/svn_util.py =================================================================== --- tools/svn_util.py (revision 465) +++ tools/svn_util.py (working copy) @@ -1,57 +1,57 @@ -# Copyright (c) 2012 The Chromium Embedded Framework Authors. All rights -# reserved. Use of this source code is governed by a BSD-style license that -# can be found in the LICENSE file. - -import os -import sys -import urllib - -def check_url(url): - """ Check the URL and raise an exception if invalid. """ - if ':' in url[:7]: - parts = url.split(':', 1) - if (parts[0] == 'http' or parts[0] == 'https' or parts[0] == 'svn') and \ - parts[1] == urllib.quote(parts[1]): - return url - sys.stderr.write('Invalid URL: '+url+"\n") - raise Exception('Invalid URL: '+url) - -def get_svn_info(path): - """ Retrieves the URL and revision from svn info. """ - url = 'None' - rev = 'None' - if path[0:4] == 'http' or os.path.exists(path): - try: - stream = os.popen('svn info '+path) - for line in stream: - if line[0:4] == "URL:": - url = check_url(line[5:-1]) - elif line[0:9] == "Revision:": - rev = str(int(line[10:-1])) - except IOError, (errno, strerror): - sys.stderr.write('Failed to read svn info: '+strerror+"\n") - raise - return {'url': url, 'revision': rev} - -def get_revision(path = '.'): - """ Retrieves the revision from svn info. """ - info = get_svn_info(path) - if info['revision'] == 'None': - raise Exception('Unable to retrieve SVN revision for "'+path+'"') - return info['revision'] - -def get_changed_files(path = '.'): - """ Retrieves the list of changed files from svn status. """ - files = [] - if os.path.exists(path): - try: - stream = os.popen('svn status '+path) - for line in stream: - status = line[0] - # Return paths with add, modify and switch status. - if status == 'A' or status == 'M' or status == 'S': - files.append(line[8:].strip()) - except IOError, (errno, strerror): - sys.stderr.write('Failed to read svn status: '+strerror+"\n") - raise - return files +# Copyright (c) 2012 The Chromium Embedded Framework Authors. All rights +# reserved. Use of this source code is governed by a BSD-style license that +# can be found in the LICENSE file. + +import os +import sys +import urllib + +def check_url(url): + """ Check the URL and raise an exception if invalid. """ + if ':' in url[:7]: + parts = url.split(':', 1) + if (parts[0] == 'http' or parts[0] == 'https' or parts[0] == 'svn') and \ + parts[1] == urllib.quote(parts[1]): + return url + sys.stderr.write('Invalid URL: '+url+"\n") + raise Exception('Invalid URL: '+url) + +def get_svn_info(path): + """ Retrieves the URL and revision from svn info. """ + url = 'None' + rev = 'None' + if path[0:4] == 'http' or os.path.exists(path): + try: + stream = os.popen('svn info '+path) + for line in stream: + if line[0:4] == "URL:": + url = check_url(line[5:-1]) + elif line[0:9] == "Revision:": + rev = str(int(line[10:-1])) + except IOError, (errno, strerror): + sys.stderr.write('Failed to read svn info: '+strerror+"\n") + raise + return {'url': url, 'revision': rev} + +def get_revision(path = '.'): + """ Retrieves the revision from svn info. """ + info = get_svn_info(path) + if info['revision'] == 'None': + raise Exception('Unable to retrieve SVN revision for "'+path+'"') + return info['revision'] + +def get_changed_files(path = '.'): + """ Retrieves the list of changed files from svn status. """ + files = [] + if os.path.exists(path): + try: + stream = os.popen('svn status '+path) + for line in stream: + status = line[0] + # Return paths with add, modify and switch status. + if status == 'A' or status == 'M' or status == 'S': + files.append(line[8:].strip()) + except IOError, (errno, strerror): + sys.stderr.write('Failed to read svn status: '+strerror+"\n") + raise + return files