diff --git a/CHROMIUM_BUILD_COMPATIBILITY.txt b/CHROMIUM_BUILD_COMPATIBILITY.txt index 672e69bff..5d837e308 100644 --- a/CHROMIUM_BUILD_COMPATIBILITY.txt +++ b/CHROMIUM_BUILD_COMPATIBILITY.txt @@ -61,3 +61,4 @@ Date | CEF Revision | Chromium Revision 2010-11-16 | /trunk@138 | /trunk@66269 2010-12-16 | /trunk@152 | /trunk@69409 2010-01-07 | /trunk@159 | /trunk@70742 +2010-01-11 | /trunk@162 | /trunk@71081 diff --git a/cef.gyp b/cef.gyp index 35a9c9406..074bfb774 100644 --- a/cef.gyp +++ b/cef.gyp @@ -137,7 +137,7 @@ # Add the WebCore resources to the bundle. 'destination': '<(PRODUCT_DIR)/cefclient.app/Contents/', 'files': [ - '../third_party/WebKit/WebCore/Resources/', + '../third_party/WebKit/Source/WebCore/Resources/', ], }, ], @@ -243,14 +243,16 @@ '../third_party/libxml/libxml.gyp:libxml', '../third_party/libxslt/libxslt.gyp:libxslt', '../third_party/modp_b64/modp_b64.gyp:modp_b64', - '../third_party/WebKit/WebCore/WebCore.gyp/WebCore.gyp:webcore', + '../third_party/WebKit/Source/WebCore/WebCore.gyp/WebCore.gyp:webcore', '../third_party/WebKit/WebKit/chromium/WebKit.gyp:webkit', '../third_party/zlib/zlib.gyp:zlib', + '../ui/ui.gyp:ui_base', '../webkit/support/webkit_support.gyp:appcache', '../webkit/support/webkit_support.gyp:blob', '../webkit/support/webkit_support.gyp:database', '../webkit/support/webkit_support.gyp:fileapi', '../webkit/support/webkit_support.gyp:glue', + '../webkit/support/webkit_support.gyp:webkit_gpu', '../webkit/support/webkit_support.gyp:webkit_resources', '../webkit/support/webkit_support.gyp:webkit_strings', 'libcef_static', @@ -442,14 +444,16 @@ '../third_party/libxml/libxml.gyp:libxml', '../third_party/libxslt/libxslt.gyp:libxslt', '../third_party/modp_b64/modp_b64.gyp:modp_b64', - '../third_party/WebKit/WebCore/WebCore.gyp/WebCore.gyp:webcore', + '../third_party/WebKit/Source/WebCore/WebCore.gyp/WebCore.gyp:webcore', '../third_party/WebKit/WebKit/chromium/WebKit.gyp:webkit', '../third_party/zlib/zlib.gyp:zlib', + '../ui/ui.gyp:ui_base', '../webkit/support/webkit_support.gyp:appcache', '../webkit/support/webkit_support.gyp:blob', '../webkit/support/webkit_support.gyp:database', '../webkit/support/webkit_support.gyp:fileapi', '../webkit/support/webkit_support.gyp:glue', + '../webkit/support/webkit_support.gyp:webkit_gpu', '../webkit/support/webkit_support.gyp:webkit_resources', '../webkit/support/webkit_support.gyp:webkit_strings', ], diff --git a/include/cef.h b/include/cef.h index 1312f4fe3..36172eb66 100644 --- a/include/cef.h +++ b/include/cef.h @@ -592,19 +592,24 @@ public: // Event called when the browser begins loading a page. The |frame| pointer // will be empty if the event represents the overall load status and not the - // load status for a particular frame. The return value is currently ignored. + // load status for a particular frame. |isMainContent| will be true if this + // load is for the main content area and not an iframe. This method may not + // be called if the load request fails. The return value is currently ignored. /*--cef()--*/ virtual RetVal HandleLoadStart(CefRefPtr browser, - CefRefPtr frame) =0; + CefRefPtr frame, + bool isMainContent) =0; // Event called when the browser is done loading a page. The |frame| pointer // will be empty if the event represents the overall load status and not the - // load status for a particular frame. This event will be generated - // irrespective of whether the request completes successfully. The return - // value is currently ignored. + // load status for a particular frame. |isMainContent| will be true if this + // load is for the main content area and not an iframe. This method will be + // called irrespective of whether the request completes successfully. The + // return value is currently ignored. /*--cef()--*/ virtual RetVal HandleLoadEnd(CefRefPtr browser, - CefRefPtr frame) =0; + CefRefPtr frame, + bool isMainContent) =0; // Supported error code values. See net\base\net_error_list.h for complete // descriptions of the error codes. diff --git a/include/cef_capi.h b/include/cef_capi.h index 97f1e0b44..40c8cd0c7 100644 --- a/include/cef_capi.h +++ b/include/cef_capi.h @@ -412,18 +412,23 @@ typedef struct _cef_handler_t // Event called when the browser begins loading a page. The |frame| pointer // will be NULL if the event represents the overall load status and not the - // load status for a particular frame. The return value is currently ignored. + // load status for a particular frame. |isMainContent| will be true (1) if + // this load is for the main content area and not an iframe. This function may + // not be called if the load request fails. The return value is currently + // ignored. enum cef_retval_t (CEF_CALLBACK *handle_load_start)( struct _cef_handler_t* self, struct _cef_browser_t* browser, - struct _cef_frame_t* frame); + struct _cef_frame_t* frame, int isMainContent); // Event called when the browser is done loading a page. The |frame| pointer // will be NULL if the event represents the overall load status and not the - // load status for a particular frame. This event will be generated - // irrespective of whether the request completes successfully. The return - // value is currently ignored. + // load status for a particular frame. |isMainContent| will be true (1) if + // this load is for the main content area and not an iframe. This function + // will be called irrespective of whether the request completes successfully. + // The return value is currently ignored. enum cef_retval_t (CEF_CALLBACK *handle_load_end)(struct _cef_handler_t* self, - struct _cef_browser_t* browser, struct _cef_frame_t* frame); + struct _cef_browser_t* browser, struct _cef_frame_t* frame, + int isMainContent); // Called when the browser fails to load a resource. |errorCode| is the error // code number and |failedUrl| is the URL that failed to load. To provide diff --git a/libcef/browser_webkit_glue.cc b/libcef/browser_webkit_glue.cc index 7cdf4bb1f..5aba80306 100644 --- a/libcef/browser_webkit_glue.cc +++ b/libcef/browser_webkit_glue.cc @@ -5,7 +5,7 @@ #include "base/compiler_specific.h" -#include "third_party/WebKit/WebCore/config.h" +#include "third_party/WebKit/Source/WebCore/config.h" MSVC_PUSH_WARNING_LEVEL(0); #include "MemoryCache.h" #include "TextEncoding.h" diff --git a/libcef/browser_webkit_glue_win.cc b/libcef/browser_webkit_glue_win.cc index a62cf297f..3c48cb9f8 100644 --- a/libcef/browser_webkit_glue_win.cc +++ b/libcef/browser_webkit_glue_win.cc @@ -9,7 +9,7 @@ #include "base/compiler_specific.h" -#include "third_party/webkit/webcore/config.h" +#include "third_party/WebKit/Source/WebCore/config.h" MSVC_PUSH_WARNING_LEVEL(0); #include "PlatformContextSkia.h" MSVC_POP_WARNING(); diff --git a/libcef/browser_webkit_init.h b/libcef/browser_webkit_init.h index 512b49cd8..7b720a6d1 100644 --- a/libcef/browser_webkit_init.h +++ b/libcef/browser_webkit_init.h @@ -25,7 +25,6 @@ #include "webkit/extensions/v8/gears_extension.h" #include "third_party/WebKit/WebKit/chromium/public/WebData.h" #include "third_party/WebKit/WebKit/chromium/public/WebDatabase.h" -#include "third_party/WebKit/WebKit/chromium/public/WebGraphicsContext3D.h" #include "third_party/WebKit/WebKit/chromium/public/WebKit.h" #include "third_party/WebKit/WebKit/chromium/public/WebRuntimeFeatures.h" #include "third_party/WebKit/WebKit/chromium/public/WebScriptController.h" @@ -43,6 +42,7 @@ #include "webkit/glue/webfileutilities_impl.h" #include "webkit/glue/webkit_glue.h" #include "webkit/glue/webkitclient_impl.h" +#include "webkit/gpu/webgraphicscontext3d_in_process_impl.h" class BrowserWebKitInit : public webkit_glue::WebKitClientImpl { @@ -229,7 +229,7 @@ class BrowserWebKitInit : public webkit_glue::WebKitClientImpl { } virtual WebKit::WebGraphicsContext3D* createGraphicsContext3D() { - return WebKit::WebGraphicsContext3D::createDefault(); + return new webkit_gpu::WebGraphicsContext3DInProcessImpl(); } WebKit::WebString queryLocalizedString( diff --git a/libcef/browser_webview_delegate.cc b/libcef/browser_webview_delegate.cc index 6b2d3431d..2a53a0739 100644 --- a/libcef/browser_webview_delegate.cc +++ b/libcef/browser_webview_delegate.cc @@ -162,12 +162,15 @@ void TranslatePopupFeatures(const WebWindowFeatures& webKitFeatures, // WebViewClient ------------------------------------------------------------- WebView* BrowserWebViewDelegate::createView(WebFrame* creator, - const WebWindowFeatures& features, - const WebString& name) { + const WebURLRequest& request, const WebWindowFeatures& features, + const WebString& name) { + CefString url; + if (!request.isNull()) + url = request.url().spec().utf16(); CefPopupFeatures cefFeatures; TranslatePopupFeatures(features, cefFeatures); CefRefPtr browser = - browser_->UIT_CreatePopupWindow(std::wstring(), cefFeatures); + browser_->UIT_CreatePopupWindow(url, cefFeatures); return browser.get() ? browser->GetWebView() : NULL; } @@ -217,34 +220,6 @@ void BrowserWebViewDelegate::printPage(WebFrame* frame) { browser_->UIT_PrintPages(frame); } -void BrowserWebViewDelegate::didStartLoading() { - // clear the title so we can tell if it wasn't provided by the page - browser_->UIT_SetTitle(std::wstring()); - - CefRefPtr handler = browser_->GetHandler(); - if(handler.get()) { - // Notify the handler that loading has started - handler->HandleLoadStart(browser_, NULL); - } -} - -void BrowserWebViewDelegate::didStopLoading() { - if(browser_->UIT_GetTitle().empty()) { - // no title was provided by the page, so send a blank string to the client - CefRefPtr handler = browser_->GetHandler(); - if(handler.get()) { - // Notify the handler of a page title change - handler->HandleTitleChange(browser_, browser_->UIT_GetTitle()); - } - } - - CefRefPtr handler = browser_->GetHandler(); - if(handler.get()) { - // Notify the handler that loading has ended - handler->HandleLoadEnd(browser_, NULL); - } -} - bool BrowserWebViewDelegate::shouldBeginEditing(const WebRange& range) { return browser_->UIT_AllowEditing(); } @@ -657,14 +632,12 @@ void BrowserWebViewDelegate::didCreateDataSource( void BrowserWebViewDelegate::didStartProvisionalLoad(WebFrame* frame) { if (!top_loading_frame_) { top_loading_frame_ = frame; + is_main_content_ = true; } - - UpdateAddressBar(frame->view()); } void BrowserWebViewDelegate::didReceiveServerRedirectForProvisionalLoad( WebFrame* frame) { - UpdateAddressBar(frame->view()); } void BrowserWebViewDelegate::didFailProvisionalLoad( @@ -720,11 +693,35 @@ void BrowserWebViewDelegate::didFailProvisionalLoad( void BrowserWebViewDelegate::didCommitProvisionalLoad( WebFrame* frame, bool is_new_navigation) { + // Determine if this commit represents the main content. + if (frame == top_loading_frame_) { + is_main_content_ = false; + if (is_new_navigation) { + // New navigations will be the main content. + is_main_content_ = true; + } else { + // Session history navigations will be the main content. + BrowserExtraData* extra_data = static_cast( + frame->dataSource()->extraData()); + if (extra_data && extra_data->pending_page_id != -1 && + !extra_data->request_committed) + is_main_content_ = true; + } + + if (is_main_content_) { + // Clear the title so we can tell if it wasn't provided by the page. + browser_->UIT_SetTitle(std::wstring()); + } + } + UpdateForCommittedLoad(frame, is_new_navigation); + CefRefPtr handler = browser_->GetHandler(); if(handler.get()) { - // Notify the handler that loading has started - handler->HandleLoadStart(browser_, browser_->GetCefFrame(frame)); + // Notify the handler that loading has started. + handler->HandleLoadStart(browser_, + (frame == top_loading_frame_) ? NULL : browser_->GetCefFrame(frame), + is_main_content_); } } @@ -746,12 +743,14 @@ void BrowserWebViewDelegate::didClearWindowObject(WebFrame* frame) { void BrowserWebViewDelegate::didReceiveTitle( WebFrame* frame, const WebString& title) { - CefString titleStr = string16(title); - browser_->UIT_SetTitle(titleStr); - CefRefPtr handler = browser_->GetHandler(); - if(handler.get()) { - // Notify the handler of a page title change - handler->HandleTitleChange(browser_, titleStr); + if (frame == top_loading_frame_ && is_main_content_) { + CefString titleStr = string16(title); + browser_->UIT_SetTitle(titleStr); + CefRefPtr handler = browser_->GetHandler(); + if(handler.get()) { + // Notify the handler of a page title change + handler->HandleTitleChange(browser_, titleStr); + } } } @@ -761,13 +760,7 @@ void BrowserWebViewDelegate::didFailLoad( } void BrowserWebViewDelegate::didFinishLoad(WebFrame* frame) { - UpdateAddressBar(frame->view()); LocationChangeDone(frame); - CefRefPtr handler = browser_->GetHandler(); - if(handler.get()) { - // Notify the handler that loading has ended - handler->HandleLoadEnd(browser_, browser_->GetCefFrame(frame)); - } } void BrowserWebViewDelegate::didChangeLocationWithinPage( @@ -821,6 +814,7 @@ BrowserWebViewDelegate::BrowserWebViewDelegate(CefBrowserImpl* browser) policy_delegate_should_notify_done_(false), browser_(browser), top_loading_frame_(NULL), + is_main_content_(false), page_id_(-1), last_page_id_updated_(-1), smart_insert_delete_enabled_(true), @@ -885,12 +879,32 @@ void BrowserWebViewDelegate::WaitForPolicyDelegate() { // Private methods ----------------------------------------------------------- -void BrowserWebViewDelegate::UpdateAddressBar(WebView* webView) { -} - void BrowserWebViewDelegate::LocationChangeDone(WebFrame* frame) { - if (frame == top_loading_frame_) + CefRefPtr handler = browser_->GetHandler(); + bool is_top_frame = false; + + if (frame == top_loading_frame_) { top_loading_frame_ = NULL; + is_top_frame = true; + + if(is_main_content_ && handler.get()) { + CefString title = browser_->UIT_GetTitle(); + if (title.empty()) { + // No title was provided by the page, so send a blank string to the + // client. + handler->HandleTitleChange(browser_, title); + } + } + } + + if(handler.get()) { + // Notify the handler that loading has ended. + handler->HandleLoadEnd(browser_, + (is_top_frame) ? NULL : browser_->GetCefFrame(frame), is_main_content_); + } + + if (is_top_frame && is_main_content_) + is_main_content_ = false; } WebWidgetHost* BrowserWebViewDelegate::GetWidgetHost() { @@ -902,7 +916,7 @@ WebWidgetHost* BrowserWebViewDelegate::GetWidgetHost() { } void BrowserWebViewDelegate::UpdateForCommittedLoad(WebFrame* frame, - bool is_new_navigation) { + bool is_new_navigation) { // Code duplicated from RenderView::DidCommitLoadForFrame. BrowserExtraData* extra_data = static_cast( frame->dataSource()->extraData()); @@ -943,12 +957,13 @@ void BrowserWebViewDelegate::UpdateURL(WebFrame* frame) { entry->SetURL(request.url()); } - std::string url = std::string(entry->GetURL().spec().c_str()); - - CefRefPtr handler = browser_->GetHandler(); - if(handler.get()) { - // Notify the handler of an address change - handler->HandleAddressChange(browser_, browser_->GetCefFrame(frame), url); + if (is_main_content_) { + CefRefPtr handler = browser_->GetHandler(); + if(handler.get()) { + // Notify the handler of an address change + std::string url = std::string(entry->GetURL().spec().c_str()); + handler->HandleAddressChange(browser_, browser_->GetCefFrame(frame), url); + } } const WebHistoryItem& history_item = frame->currentHistoryItem(); diff --git a/libcef/browser_webview_delegate.h b/libcef/browser_webview_delegate.h index 8f314c357..b9081e062 100644 --- a/libcef/browser_webview_delegate.h +++ b/libcef/browser_webview_delegate.h @@ -51,9 +51,9 @@ class BrowserWebViewDelegate : public WebKit::WebViewClient, public base::SupportsWeakPtr { public: // WebKit::WebViewClient - virtual WebKit::WebView* createView(WebKit::WebFrame* creator, - const WebKit::WebWindowFeatures& features, - const WebKit::WebString& name); + virtual WebKit::WebView* createView( + WebKit::WebFrame* creator, const WebKit::WebURLRequest& request, + const WebKit::WebWindowFeatures& features, const WebKit::WebString& name); virtual WebKit::WebWidget* createPopupMenu(WebKit::WebPopupType popup_type); virtual WebKit::WebWidget* createPopupMenu( const WebKit::WebPopupMenuInfo& info); @@ -63,8 +63,6 @@ class BrowserWebViewDelegate : public WebKit::WebViewClient, const WebKit::WebConsoleMessage& message, const WebKit::WebString& source_name, unsigned source_line); virtual void printPage(WebKit::WebFrame* frame); - virtual void didStartLoading(); - virtual void didStopLoading(); virtual bool shouldBeginEditing(const WebKit::WebRange& range); virtual bool shouldEndEditing(const WebKit::WebRange& range); virtual bool shouldInsertNode( @@ -248,9 +246,6 @@ class BrowserWebViewDelegate : public WebKit::WebViewClient, CefBrowserImpl* GetBrowser() { return browser_; } protected: - // Called when the URL of the page changes. - void UpdateAddressBar(WebKit::WebView* webView); - // Default handling of JavaScript messages. void ShowJavaScriptAlert(WebKit::WebFrame* webframe, const CefString& message); @@ -295,8 +290,10 @@ class BrowserWebViewDelegate : public WebKit::WebViewClient, // Non-owning pointer. The delegate is owned by the host. CefBrowserImpl* browser_; - // This is non-NULL IFF a load is in progress. + // This is non-NULL if a load is in progress. WebKit::WebFrame* top_loading_frame_; + // This is true if the in-progress load is the main content. + bool is_main_content_; // For tracking session history. See RenderView. int page_id_; diff --git a/libcef/simple_clipboard_impl.cc b/libcef/simple_clipboard_impl.cc index 95a33ebd2..ef290c711 100644 --- a/libcef/simple_clipboard_impl.cc +++ b/libcef/simple_clipboard_impl.cc @@ -6,11 +6,11 @@ #include -#include "app/clipboard/clipboard.h" #include "base/lazy_instance.h" #include "base/string16.h" #include "googleurl/src/gurl.h" #include "third_party/skia/include/core/SkBitmap.h" +#include "ui/base/clipboard/clipboard.h" #include "webkit/glue/scoped_clipboard_writer_glue.h" // Clipboard glue @@ -25,26 +25,27 @@ ScopedClipboardWriterGlue::~ScopedClipboardWriterGlue() { namespace webkit_glue { -base::LazyInstance clipboard(base::LINKER_INITIALIZED); +base::LazyInstance clipboard(base::LINKER_INITIALIZED); -Clipboard* ClipboardGetClipboard() { +ui::Clipboard* ClipboardGetClipboard() { return clipboard.Pointer(); } -bool ClipboardIsFormatAvailable(const Clipboard::FormatType& format, - Clipboard::Buffer buffer) { +bool ClipboardIsFormatAvailable(const ui::Clipboard::FormatType& format, + ui::Clipboard::Buffer buffer) { return ClipboardGetClipboard()->IsFormatAvailable(format, buffer); } -void ClipboardReadText(Clipboard::Buffer buffer, string16* result) { +void ClipboardReadText(ui::Clipboard::Buffer buffer, string16* result) { ClipboardGetClipboard()->ReadText(buffer, result); } -void ClipboardReadAsciiText(Clipboard::Buffer buffer, std::string* result) { +void ClipboardReadAsciiText(ui::Clipboard::Buffer buffer, std::string* result) { ClipboardGetClipboard()->ReadAsciiText(buffer, result); } -void ClipboardReadHTML(Clipboard::Buffer buffer, string16* markup, GURL* url) { +void ClipboardReadHTML(ui::Clipboard::Buffer buffer, string16* markup, + GURL* url) { std::string url_str; ClipboardGetClipboard()->ReadHTML(buffer, markup, url ? &url_str : NULL); if (url) @@ -52,18 +53,18 @@ void ClipboardReadHTML(Clipboard::Buffer buffer, string16* markup, GURL* url) { } // TODO(dcheng): Implement. -bool ClipboardReadAvailableTypes(Clipboard::Buffer buffer, +bool ClipboardReadAvailableTypes(ui::Clipboard::Buffer buffer, std::vector* types, bool* contains_filenames) { return false; } -bool ClipboardReadData(Clipboard::Buffer buffer, const string16& type, +bool ClipboardReadData(ui::Clipboard::Buffer buffer, const string16& type, string16* data, string16* metadata) { return false; } -bool ClipboardReadFilenames(Clipboard::Buffer buffer, +bool ClipboardReadFilenames(ui::Clipboard::Buffer buffer, std::vector* filenames) { return false; } diff --git a/libcef/webview_host_gtk.cc b/libcef/webview_host_gtk.cc index bcd2b1ed4..e50fd1316 100644 --- a/libcef/webview_host_gtk.cc +++ b/libcef/webview_host_gtk.cc @@ -29,7 +29,11 @@ WebViewHost* WebViewHost::Create(GtkWidget* parent_view, host->view_ = WebWidgetHost::CreateWidget(parent_view, host); host->plugin_container_manager_.set_host_widget(host->view_); +#if defined(WEBKIT_HAS_WEB_AUTO_FILL_CLIENT) + host->webwidget_ = WebView::create(delegate, dev_tools_client, NULL); +#else host->webwidget_ = WebView::create(delegate, dev_tools_client); +#endif prefs.Apply(host->webview()); host->webview()->initializeMainFrame(delegate); host->webwidget_->layout(); diff --git a/libcef/webview_host_mac.mm b/libcef/webview_host_mac.mm index 2711bbe6c..fe4c2b4e0 100644 --- a/libcef/webview_host_mac.mm +++ b/libcef/webview_host_mac.mm @@ -34,7 +34,11 @@ WebViewHost* WebViewHost::Create(NSView* parent_view, [parent_view addSubview:host->view_]; [host->view_ release]; +#if defined(WEBKIT_HAS_WEB_AUTO_FILL_CLIENT) + host->webwidget_ = WebView::create(delegate, dev_tools_client, NULL); +#else host->webwidget_ = WebView::create(delegate, dev_tools_client); +#endif prefs.Apply(host->webview()); host->webview()->initializeMainFrame(delegate); host->webwidget_->resize(WebSize(content_rect.size.width, diff --git a/libcef/webview_host_win.cc b/libcef/webview_host_win.cc index 59c902807..cf3b5f6f4 100644 --- a/libcef/webview_host_win.cc +++ b/libcef/webview_host_win.cc @@ -42,7 +42,11 @@ WebViewHost* WebViewHost::Create(HWND parent_view, GetModuleHandle(NULL), NULL); app::win::SetWindowUserData(host->view_, host); +#if defined(WEBKIT_HAS_WEB_AUTO_FILL_CLIENT) + host->webwidget_ = WebView::create(delegate, dev_tools_client, NULL); +#else host->webwidget_ = WebView::create(delegate, dev_tools_client); +#endif prefs.Apply(host->webview()); host->webview()->initializeMainFrame(delegate); diff --git a/libcef_dll/cpptoc/handler_cpptoc.cc b/libcef_dll/cpptoc/handler_cpptoc.cc index 9f4c5bf72..92231ab74 100644 --- a/libcef_dll/cpptoc/handler_cpptoc.cc +++ b/libcef_dll/cpptoc/handler_cpptoc.cc @@ -135,7 +135,8 @@ enum cef_retval_t CEF_CALLBACK handler_handle_before_browse( } enum cef_retval_t CEF_CALLBACK handler_handle_load_start( - struct _cef_handler_t* self, cef_browser_t* browser, cef_frame_t* frame) + struct _cef_handler_t* self, cef_browser_t* browser, cef_frame_t* frame, + int isMainContent) { DCHECK(self); DCHECK(browser); @@ -147,11 +148,12 @@ enum cef_retval_t CEF_CALLBACK handler_handle_load_start( framePtr = CefFrameCToCpp::Wrap(frame); return CefHandlerCppToC::Get(self)->HandleLoadStart( - CefBrowserCToCpp::Wrap(browser), framePtr); + CefBrowserCToCpp::Wrap(browser), framePtr, isMainContent?true:false); } enum cef_retval_t CEF_CALLBACK handler_handle_load_end( - struct _cef_handler_t* self, cef_browser_t* browser, cef_frame_t* frame) + struct _cef_handler_t* self, cef_browser_t* browser, cef_frame_t* frame, + int isMainContent) { DCHECK(self); DCHECK(browser); @@ -163,7 +165,7 @@ enum cef_retval_t CEF_CALLBACK handler_handle_load_end( framePtr = CefFrameCToCpp::Wrap(frame); return CefHandlerCppToC::Get(self)->HandleLoadEnd( - CefBrowserCToCpp::Wrap(browser), framePtr); + CefBrowserCToCpp::Wrap(browser), framePtr, isMainContent?true:false); } enum cef_retval_t CEF_CALLBACK handler_handle_load_error( diff --git a/libcef_dll/ctocpp/handler_ctocpp.cc b/libcef_dll/ctocpp/handler_ctocpp.cc index 55bf57c8d..7a398c4a6 100644 --- a/libcef_dll/ctocpp/handler_ctocpp.cc +++ b/libcef_dll/ctocpp/handler_ctocpp.cc @@ -98,7 +98,8 @@ CefHandler::RetVal CefHandlerCToCpp::HandleBeforeBrowse( } CefHandler::RetVal CefHandlerCToCpp::HandleLoadStart( - CefRefPtr browser, CefRefPtr frame) + CefRefPtr browser, CefRefPtr frame, + bool isMainContent) { if(CEF_MEMBER_MISSING(struct_, handle_load_start)) return RV_CONTINUE; @@ -108,11 +109,12 @@ CefHandler::RetVal CefHandlerCToCpp::HandleLoadStart( frameStruct = CefFrameCppToC::Wrap(frame); return struct_->handle_load_start(struct_, CefBrowserCppToC::Wrap(browser), - frameStruct); + frameStruct, isMainContent); } CefHandler::RetVal CefHandlerCToCpp::HandleLoadEnd( - CefRefPtr browser, CefRefPtr frame) + CefRefPtr browser, CefRefPtr frame, + bool isMainContent) { if(CEF_MEMBER_MISSING(struct_, handle_load_end)) return RV_CONTINUE; @@ -122,7 +124,7 @@ CefHandler::RetVal CefHandlerCToCpp::HandleLoadEnd( frameStruct = CefFrameCppToC::Wrap(frame); return struct_->handle_load_end(struct_, CefBrowserCppToC::Wrap(browser), - frameStruct); + frameStruct, isMainContent); } CefHandler::RetVal CefHandlerCToCpp::HandleLoadError( diff --git a/libcef_dll/ctocpp/handler_ctocpp.h b/libcef_dll/ctocpp/handler_ctocpp.h index 68b1a10e9..a5cdecc3d 100644 --- a/libcef_dll/ctocpp/handler_ctocpp.h +++ b/libcef_dll/ctocpp/handler_ctocpp.h @@ -44,9 +44,9 @@ public: CefRefPtr frame, CefRefPtr request, NavType navType, bool isRedirect); virtual RetVal HandleLoadStart(CefRefPtr browser, - CefRefPtr frame); + CefRefPtr frame, bool isMainContent); virtual RetVal HandleLoadEnd(CefRefPtr browser, - CefRefPtr frame); + CefRefPtr frame, bool isMainContent); virtual RetVal HandleLoadError(CefRefPtr browser, CefRefPtr frame, ErrorCode errorCode, const CefString& failedUrl, CefString& errorText); diff --git a/tests/cefclient/cefclient.cpp b/tests/cefclient/cefclient.cpp index 642d1411a..1d1b80f22 100644 --- a/tests/cefclient/cefclient.cpp +++ b/tests/cefclient/cefclient.cpp @@ -60,7 +60,7 @@ CefHandler::RetVal ClientHandler::HandleAfterCreated( } CefHandler::RetVal ClientHandler::HandleLoadStart(CefRefPtr browser, - CefRefPtr frame) + CefRefPtr frame, bool isMainContent) { if(!browser->IsPopup() && !frame.get()) { @@ -75,7 +75,7 @@ CefHandler::RetVal ClientHandler::HandleLoadStart(CefRefPtr browser, } CefHandler::RetVal ClientHandler::HandleLoadEnd(CefRefPtr browser, - CefRefPtr frame) + CefRefPtr frame, bool isMainContent) { if(!browser->IsPopup() && !frame.get()) { @@ -363,3 +363,8 @@ void RunHTML5VideoTest(CefRefPtr browser) browser->GetMainFrame()->LoadURL( "http://www.youtube.com/watch?v=siOHh0uzcuY&html5=True"); } + +void RunXMLHTTPRequestTest(CefRefPtr browser) +{ + browser->GetMainFrame()->LoadURL("http://tests/xmlhttprequest"); +} diff --git a/tests/cefclient/cefclient.h b/tests/cefclient/cefclient.h index d53e534ce..5627b9c7b 100644 --- a/tests/cefclient/cefclient.h +++ b/tests/cefclient/cefclient.h @@ -45,10 +45,7 @@ public: const CefPopupFeatures& popupFeatures, CefRefPtr& handler, CefString& url, - CefBrowserSettings& settings) - { - return RV_CONTINUE; - } + CefBrowserSettings& settings); // Event called after a new window is created. The return value is currently // ignored. @@ -78,17 +75,22 @@ public: // Event called when the browser begins loading a page. The |frame| pointer // will be empty if the event represents the overall load status and not the - // load status for a particular frame. The return value is currently ignored. + // load status for a particular frame. |isMainContent| will be true if this + // load is for the main content area and not an iframe. This method may not + // be called if the load request fails. The return value is currently ignored. virtual RetVal HandleLoadStart(CefRefPtr browser, - CefRefPtr frame); + CefRefPtr frame, + bool isMainContent); // Event called when the browser is done loading a page. The |frame| pointer // will be empty if the event represents the overall load status and not the - // load status for a particular frame. This event will be generated - // irrespective of whether the request completes successfully. The return - // value is currently ignored. + // load status for a particular frame. |isMainContent| will be true if this + // load is for the main content area and not an iframe. This method will be + // called irrespective of whether the request completes successfully. The + // return value is currently ignored. virtual RetVal HandleLoadEnd(CefRefPtr browser, - CefRefPtr frame); + CefRefPtr frame, + bool isMainContent); // Called when the browser fails to load a resource. |errorCode| is the // error code number and |failedUrl| is the URL that failed to load. To @@ -381,5 +383,6 @@ void RunAccelerated2DCanvasTest(CefRefPtr browser); void RunAcceleratedLayersTest(CefRefPtr browser); void RunWebGLTest(CefRefPtr browser); void RunHTML5VideoTest(CefRefPtr browser); +void RunXMLHTTPRequestTest(CefRefPtr browser); #endif // _CEFCLIENT_H diff --git a/tests/cefclient/cefclient.rc b/tests/cefclient/cefclient.rc index 2a56487da..db33903cd 100644 --- a/tests/cefclient/cefclient.rc +++ b/tests/cefclient/cefclient.rc @@ -28,10 +28,11 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US // Binary // -IDS_LOGO BINARY "res\logo.png" -IDS_UIPLUGIN BINARY "res\uiplugin.html" -IDS_LOGOBALL BINARY "res\logoball.png" -IDS_LOCALSTORAGE BINARY "res\localstorage.html" +IDS_LOGO BINARY "res\\logo.png" +IDS_UIPLUGIN BINARY "res\\uiplugin.html" +IDS_LOGOBALL BINARY "res\\logoball.png" +IDS_LOCALSTORAGE BINARY "res\\localstorage.html" +IDS_XMLHTTPREQUEST BINARY "res\\xmlhttprequest.html" ///////////////////////////////////////////////////////////////////////////// // @@ -75,6 +76,7 @@ BEGIN MENUITEM "Scheme Handler", ID_TESTS_SCHEME_HANDLER MENUITEM "UI App Example", ID_TESTS_UIAPP MENUITEM "Local Storage", ID_TESTS_LOCALSTORAGE + MENUITEM "XMLHttpRequest", ID_TESTS_XMLHTTPREQUEST MENUITEM "Accelerated 2D Canvas", ID_TESTS_ACCELERATED2DCANVAS MENUITEM "Accelerated Layers", ID_TESTS_ACCELERATEDLAYERS MENUITEM "WebGL", ID_TESTS_WEBGL diff --git a/tests/cefclient/cefclient_mac.mm b/tests/cefclient/cefclient_mac.mm index da370d964..02d652d6b 100644 --- a/tests/cefclient/cefclient_mac.mm +++ b/tests/cefclient/cefclient_mac.mm @@ -367,6 +367,14 @@ int main(int argc, char* argv[]) // ClientHandler implementation +CefHandler::RetVal ClientHandler::HandleBeforeCreated( + CefRefPtr parentBrowser, CefWindowInfo& createInfo, bool popup, + const CefPopupFeatures& popupFeatures, CefRefPtr& handler, + CefString& url, CefBrowserSettings& settings) +{ + return RV_CONTINUE; +} + CefHandler::RetVal ClientHandler::HandleAddressChange( CefRefPtr browser, CefRefPtr frame, const CefString& url) diff --git a/tests/cefclient/cefclient_win.cpp b/tests/cefclient/cefclient_win.cpp index 2798fcd81..ffae9bc83 100644 --- a/tests/cefclient/cefclient_win.cpp +++ b/tests/cefclient/cefclient_win.cpp @@ -69,9 +69,6 @@ int APIENTRY wWinMain(HINSTANCE hInstance, // Specify a cache path value. //CefString(&settings.cache_path).FromASCII("c:\\temp\\cache"); - // Disable accelerated compositing to view HTML5 video. - //browserDefaults.accelerated_compositing_disabled = true; - #ifdef TEST_SINGLE_THREADED_MESSAGE_LOOP // Initialize the CEF with messages processed using the current application's // message loop. @@ -567,6 +564,10 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) if(browser.get()) RunHTML5VideoTest(browser); return 0; + case ID_TESTS_XMLHTTPREQUEST: // Test XMLHttpRequest + if(browser.get()) + RunXMLHTTPRequestTest(browser); + return 0; } } break; @@ -648,6 +649,25 @@ INT_PTR CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) // ClientHandler implementation +CefHandler::RetVal ClientHandler::HandleBeforeCreated( + CefRefPtr parentBrowser, CefWindowInfo& createInfo, bool popup, + const CefPopupFeatures& popupFeatures, CefRefPtr& handler, + CefString& url, CefBrowserSettings& settings) +{ + if(popup) { + if(popupFeatures.xSet) + createInfo.m_x = popupFeatures.x; + if(popupFeatures.ySet) + createInfo.m_y = popupFeatures.y; + if(popupFeatures.widthSet) + createInfo.m_nWidth = popupFeatures.width; + if(popupFeatures.heightSet) + createInfo.m_nHeight = popupFeatures.height; + } + + return RV_CONTINUE; +} + CefHandler::RetVal ClientHandler::HandleAddressChange( CefRefPtr browser, CefRefPtr frame, const CefString& url) @@ -687,8 +707,8 @@ CefHandler::RetVal ClientHandler::HandleBeforeResourceLoad( // Show the request contents std::string dump; DumpRequestContents(request, dump); - resourceStream = CefStreamReader::CreateForData((void*)dump.c_str(), - dump.size()); + resourceStream = + CefStreamReader::CreateForData((void*)dump.c_str(), dump.size()); mimeType = "text/plain"; } else if(url == "http://tests/uiapp") { // Show the uiapp contents @@ -704,6 +724,13 @@ CefHandler::RetVal ClientHandler::HandleBeforeResourceLoad( new CefByteReadHandler(pBytes, dwSize, NULL)); mimeType = "text/html"; } + } else if(url == "http://tests/xmlhttprequest") { + // Show the xmlhttprequest HTML contents + if(LoadBinaryResource(IDS_XMLHTTPREQUEST, dwSize, pBytes)) { + resourceStream = CefStreamReader::CreateForHandler( + new CefByteReadHandler(pBytes, dwSize, NULL)); + mimeType = "text/html"; + } } else if(strstr(url.c_str(), "/ps_logo2.png") != NULL) { // Any time we find "ps_logo2.png" in the URL substitute in our own image if(LoadBinaryResource(IDS_LOGO, dwSize, pBytes)) { diff --git a/tests/cefclient/res/xmlhttprequest.html b/tests/cefclient/res/xmlhttprequest.html new file mode 100644 index 000000000..5115bcff4 --- /dev/null +++ b/tests/cefclient/res/xmlhttprequest.html @@ -0,0 +1,18 @@ + + + +
+ +
+
+ + diff --git a/tests/cefclient/resource.h b/tests/cefclient/resource.h index 34857b71d..c096d494a 100644 --- a/tests/cefclient/resource.h +++ b/tests/cefclient/resource.h @@ -41,11 +41,13 @@ #define ID_TESTS_ACCELERATEDLAYERS 32781 #define ID_TESTS_WEBGL 32782 #define ID_TESTS_HTML5VIDEO 32783 +#define ID_TESTS_XMLHTTPREQUEST 32784 #define IDC_STATIC -1 #define IDS_LOGO 1000 #define IDS_UIPLUGIN 1001 #define IDS_LOGOBALL 1002 #define IDS_LOCALSTORAGE 1003 +#define IDS_XMLHTTPREQUEST 1004 // Avoid files associated with MacOS #define _X86_ diff --git a/tests/unittests/request_unittest.cc b/tests/unittests/request_unittest.cc index c37f919e1..fb6a6f39f 100644 --- a/tests/unittests/request_unittest.cc +++ b/tests/unittests/request_unittest.cc @@ -272,7 +272,8 @@ public: } virtual RetVal HandleLoadEnd(CefRefPtr browser, - CefRefPtr frame) + CefRefPtr frame, + bool isMainContent) { if(!browser->IsPopup() && !frame.get()) DestroyTest(); @@ -380,7 +381,8 @@ public: } virtual RetVal HandleLoadEnd(CefRefPtr browser, - CefRefPtr frame) + CefRefPtr frame, + bool isMainContent) { if(!browser->IsPopup() && !frame.get()) { diff --git a/tests/unittests/test_handler.h b/tests/unittests/test_handler.h index 4ffc8f307..4c6ad3f96 100644 --- a/tests/unittests/test_handler.h +++ b/tests/unittests/test_handler.h @@ -69,13 +69,15 @@ public: } virtual RetVal HandleLoadStart(CefRefPtr browser, - CefRefPtr frame) + CefRefPtr frame, + bool isMainContent) { return RV_CONTINUE; } virtual RetVal HandleLoadEnd(CefRefPtr browser, - CefRefPtr frame) + CefRefPtr frame, + bool isMainContent) { return RV_CONTINUE; } diff --git a/tests/unittests/v8_unittest.cc b/tests/unittests/v8_unittest.cc index 31b511294..7bd4ca45f 100644 --- a/tests/unittests/v8_unittest.cc +++ b/tests/unittests/v8_unittest.cc @@ -247,7 +247,8 @@ public: } virtual RetVal HandleLoadEnd(CefRefPtr browser, - CefRefPtr frame) + CefRefPtr frame, + bool isMainContent) { if(!browser->IsPopup() && !frame.get()) DestroyTest();