diff --git a/libcef/browser/browser_host_impl.cc b/libcef/browser/browser_host_impl.cc index a385be74e..d44938bf8 100644 --- a/libcef/browser/browser_host_impl.cc +++ b/libcef/browser/browser_host_impl.cc @@ -1591,21 +1591,6 @@ void CefBrowserHostImpl::DocumentAvailableInMainFrame() { has_document_ = true; } -void CefBrowserHostImpl::DidFinishLoad( - int64 frame_id, - const GURL& validated_url, - bool is_main_frame, - content::RenderViewHost* render_view_host) { - CefRefPtr frame = GetOrCreateFrame(frame_id, - CefFrameHostImpl::kUnspecifiedFrameId, is_main_frame, string16(), - validated_url); - - // Give internal scheme handlers an opportunity to update content. - scheme::DidFinishLoad(frame, validated_url); - - OnLoadEnd(frame, validated_url); -} - void CefBrowserHostImpl::DidFailLoad( int64 frame_id, const GURL& validated_url, @@ -1617,7 +1602,7 @@ void CefBrowserHostImpl::DidFailLoad( CefFrameHostImpl::kUnspecifiedFrameId, is_main_frame, string16(), validated_url); OnLoadError(frame, validated_url, error_code, error_description); - OnLoadEnd(frame, validated_url); + OnLoadEnd(frame, validated_url, error_code); } void CefBrowserHostImpl::PluginCrashed(const FilePath& plugin_path) { @@ -1634,6 +1619,7 @@ bool CefBrowserHostImpl::OnMessageReceived(const IPC::Message& message) { IPC_MESSAGE_HANDLER(CefHostMsg_FrameIdentified, OnFrameIdentified) IPC_MESSAGE_HANDLER(CefHostMsg_FrameDetached, DetachFrame) IPC_MESSAGE_HANDLER(CefHostMsg_FrameFocusChange, SetFocusedFrame) + IPC_MESSAGE_HANDLER(CefHostMsg_DidFinishLoad, OnDidFinishLoad) IPC_MESSAGE_HANDLER(CefHostMsg_LoadingURLChange, OnLoadingURLChange) IPC_MESSAGE_HANDLER(CefHostMsg_Request, OnRequest) IPC_MESSAGE_HANDLER(CefHostMsg_Response, OnResponse) @@ -1670,6 +1656,20 @@ void CefBrowserHostImpl::OnFrameIdentified(int64 frame_id, GetOrCreateFrame(frame_id, parent_frame_id, is_main_frame, name, GURL()); } +void CefBrowserHostImpl::OnDidFinishLoad(int64 frame_id, + const GURL& validated_url, + bool is_main_frame, + int http_status_code) { + CefRefPtr frame = GetOrCreateFrame(frame_id, + CefFrameHostImpl::kUnspecifiedFrameId, is_main_frame, string16(), + validated_url); + + // Give internal scheme handlers an opportunity to update content. + scheme::DidFinishLoad(frame, validated_url); + + OnLoadEnd(frame, validated_url, http_status_code); +} + void CefBrowserHostImpl::OnLoadingURLChange(const GURL& loading_url) { base::AutoLock lock_scope(state_lock_); loading_url_ = loading_url; @@ -1952,14 +1952,12 @@ void CefBrowserHostImpl::OnLoadError(CefRefPtr frame, } void CefBrowserHostImpl::OnLoadEnd(CefRefPtr frame, - const GURL& url) { + const GURL& url, + int http_status_code) { if (client_.get()) { CefRefPtr handler = client_->GetLoadHandler(); - if (handler.get()) { - // Notify the handler that loading has ended. - // TODO(cef): Identify the HTTP status code. - handler->OnLoadEnd(this, frame, 200); - } + if (handler.get()) + handler->OnLoadEnd(this, frame, http_status_code); } } diff --git a/libcef/browser/browser_host_impl.h b/libcef/browser/browser_host_impl.h index e9170c0d9..4c6ed3683 100644 --- a/libcef/browser/browser_host_impl.h +++ b/libcef/browser/browser_host_impl.h @@ -158,7 +158,6 @@ class CefBrowserHostImpl : public CefBrowserHost, CefProcessId target_process, CefRefPtr message) OVERRIDE; - // Call LifeSpanHandler before destroying. Returns true if destruction // is allowed at this time. bool AllowDestroyBrowser(); @@ -313,11 +312,6 @@ class CefBrowserHostImpl : public CefBrowserHost, const string16& error_description, content::RenderViewHost* render_view_host) OVERRIDE; virtual void DocumentAvailableInMainFrame() OVERRIDE; - virtual void DidFinishLoad(int64 frame_id, - const GURL& validated_url, - bool is_main_frame, - content::RenderViewHost* render_view_host) - OVERRIDE; virtual void DidFailLoad(int64 frame_id, const GURL& validated_url, bool is_main_frame, @@ -331,6 +325,11 @@ class CefBrowserHostImpl : public CefBrowserHost, // content::WebContentsObserver::OnMessageReceived() message handlers. void OnFrameIdentified(int64 frame_id, int64 parent_frame_id, string16 name); + void OnDidFinishLoad( + int64 frame_id, + const GURL& validated_url, + bool is_main_frame, + int http_status_code); void OnLoadingURLChange(const GURL& pending_url); void OnRequest(const Cef_Request_Params& params); void OnResponse(const Cef_Response_Params& params); @@ -413,7 +412,8 @@ class CefBrowserHostImpl : public CefBrowserHost, int error_code, const string16& error_description); void OnLoadEnd(CefRefPtr frame, - const GURL& url); + const GURL& url, + int http_status_code); // Continuation from RunFileChooser. void RunFileChooserOnUIThread(const content::FileChooserParams& params, diff --git a/libcef/common/cef_messages.h b/libcef/common/cef_messages.h index 0175cd657..040064658 100644 --- a/libcef/common/cef_messages.h +++ b/libcef/common/cef_messages.h @@ -172,6 +172,13 @@ IPC_MESSAGE_ROUTED1(CefHostMsg_FrameDetached, IPC_MESSAGE_ROUTED1(CefHostMsg_FrameFocusChange, int64 /* frame_id */) +// Sent when a frame has finished loading. Based on ViewHostMsg_DidFinishLoad. +IPC_MESSAGE_ROUTED4(CefHostMsg_DidFinishLoad, + int64 /* frame_id */, + GURL /* validated_url */, + bool /* is_main_frame */, + int /* http_status_code */) + // Sent when a new URL is about to be loaded in the main frame. Used for the // cookie manager. IPC_MESSAGE_ROUTED1(CefHostMsg_LoadingURLChange, diff --git a/libcef/renderer/browser_impl.cc b/libcef/renderer/browser_impl.cc index 4da3c466c..7b073a60b 100644 --- a/libcef/renderer/browser_impl.cc +++ b/libcef/renderer/browser_impl.cc @@ -24,6 +24,7 @@ #include "content/public/renderer/navigation_state.h" #include "content/public/renderer/render_view.h" #include "net/http/http_util.h" +#include "third_party/WebKit/Source/Platform/chromium/public/WebURLResponse.h" #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h" #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURL.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebDataSource.h" @@ -443,6 +444,15 @@ void CefBrowserImpl::OnDestruct() { CefContentRendererClient::Get()->OnBrowserDestroyed(this); } +void CefBrowserImpl::DidFinishLoad(WebKit::WebFrame* frame) { + WebKit::WebDataSource* ds = frame->dataSource(); + Send(new CefHostMsg_DidFinishLoad(routing_id(), + frame->identifier(), + ds->request().url(), + !frame->parent(), + ds->response().httpStatusCode())); +} + void CefBrowserImpl::DidStartProvisionalLoad(WebKit::WebFrame* frame) { // Send the frame creation notification if necessary. GetWebFrameImpl(frame); diff --git a/libcef/renderer/browser_impl.h b/libcef/renderer/browser_impl.h index 939ed81cf..d23f43f9a 100644 --- a/libcef/renderer/browser_impl.h +++ b/libcef/renderer/browser_impl.h @@ -104,6 +104,7 @@ class CefBrowserImpl : public CefBrowser, private: // RenderViewObserver methods. virtual void OnDestruct() OVERRIDE; + virtual void DidFinishLoad(WebKit::WebFrame* frame) OVERRIDE; virtual void DidStartProvisionalLoad(WebKit::WebFrame* frame) OVERRIDE; virtual void FrameDetached(WebKit::WebFrame* frame) OVERRIDE; virtual void FocusedNodeChanged(const WebKit::WebNode& node) OVERRIDE; diff --git a/tests/unittests/scheme_handler_unittest.cc b/tests/unittests/scheme_handler_unittest.cc index 23ddb173f..421b74998 100644 --- a/tests/unittests/scheme_handler_unittest.cc +++ b/tests/unittests/scheme_handler_unittest.cc @@ -125,9 +125,7 @@ class TestSchemeHandler : public TestHandler { test_results_->got_output.yes(); // Test that the status code is correct. - // TODO(cef): Enable this check once the HTTP status code is passed - // correctly. - // EXPECT_EQ(httpStatusCode, test_results_->status_code); + EXPECT_EQ(httpStatusCode, test_results_->status_code); if (test_results_->sub_url.empty()) DestroyTest();