From 7db4fae994f8d391065f49bda0a2b050602ed509 Mon Sep 17 00:00:00 2001 From: bridiver Date: Sun, 14 Feb 2016 16:31:13 -0700 Subject: [PATCH] add load-start event auditors: @bbondy --- atom/browser/lib/guest-view-manager.js | 1 + atom/browser/web_view_guest_delegate.cc | 9 +++++++++ atom/browser/web_view_guest_delegate.h | 5 +++++ atom/renderer/lib/web-view/guest-view-internal.js | 1 + 4 files changed, 16 insertions(+) diff --git a/atom/browser/lib/guest-view-manager.js b/atom/browser/lib/guest-view-manager.js index 374d6972b4..b3d7d6b14b 100644 --- a/atom/browser/lib/guest-view-manager.js +++ b/atom/browser/lib/guest-view-manager.js @@ -9,6 +9,7 @@ var slice = [].slice; var webViewManager = null; var supportedWebViewEvents = [ + 'load-start', 'load-commit', 'did-finish-load', 'did-fail-load', diff --git a/atom/browser/web_view_guest_delegate.cc b/atom/browser/web_view_guest_delegate.cc index da051709f4..01ec9cc5bc 100644 --- a/atom/browser/web_view_guest_delegate.cc +++ b/atom/browser/web_view_guest_delegate.cc @@ -182,6 +182,15 @@ void WebViewGuestDelegate::RenderViewReady() { render_view_host_view->SetBackgroundColor(SK_ColorTRANSPARENT); } +void WebViewGuestDelegate::DidStartProvisionalLoadForFrame( + content::RenderFrameHost* render_frame_host, + const GURL& url, + bool is_error_page, + bool is_iframe_srcdoc) { + api_web_contents_->Emit("load-start", url, !render_frame_host->GetParent(), + is_error_page, is_iframe_srcdoc); +} + void WebViewGuestDelegate::DidCommitProvisionalLoadForFrame( content::RenderFrameHost* render_frame_host, const GURL& url, ui::PageTransition transition_type) { diff --git a/atom/browser/web_view_guest_delegate.h b/atom/browser/web_view_guest_delegate.h index b5f62c3ec1..3f7b8375d2 100644 --- a/atom/browser/web_view_guest_delegate.h +++ b/atom/browser/web_view_guest_delegate.h @@ -68,6 +68,11 @@ class WebViewGuestDelegate : public content::BrowserPluginGuestDelegate, protected: // content::WebContentsObserver: void RenderViewReady() override; + void DidStartProvisionalLoadForFrame( + content::RenderFrameHost* render_frame_host, + const GURL& validated_url, + bool is_error_page, + bool is_iframe_srcdoc) override; void DidCommitProvisionalLoadForFrame( content::RenderFrameHost* render_frame_host, const GURL& url, ui::PageTransition transition_type) override; diff --git a/atom/renderer/lib/web-view/guest-view-internal.js b/atom/renderer/lib/web-view/guest-view-internal.js index 2e60c79fdf..4f122d9b4b 100644 --- a/atom/renderer/lib/web-view/guest-view-internal.js +++ b/atom/renderer/lib/web-view/guest-view-internal.js @@ -5,6 +5,7 @@ var slice = [].slice; var requestId = 0; var WEB_VIEW_EVENTS = { + 'load-start': ['url', 'isMainFrame', 'isErrorPage', 'isFrameSrcDoc'], 'load-commit': ['url', 'isMainFrame'], 'did-finish-load': [], 'did-fail-load': ['errorCode', 'errorDescription', 'validatedURL'],