#include "content/public/browser/render_process_host.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/render_widget_host_view.h"
+#include "content/public/browser/resource_request_details.h"
#include "content/public/browser/site_instance.h"
#include "content/public/browser/web_contents.h"
#include "native_mate/dictionary.h"
Emit("did-finish-load");
}
+void WebContents::DidFailLoad(content::RenderFrameHost* render_frame_host,
+ const GURL& validated_url,
+ int error_code,
+ const base::string16& error_description) {
+ base::ListValue args;
+ args.AppendInteger(error_code);
+ args.AppendString(error_description);
+ Emit("did-fail-load", args);
+}
+
void WebContents::DidStartLoading(content::RenderViewHost* render_view_host) {
Emit("did-start-loading");
}
Emit("did-stop-loading");
}
+void WebContents::DidGetRedirectForResourceRequest(
+ content::RenderViewHost* render_view_host,
+ const content::ResourceRedirectDetails& details) {
+ base::ListValue args;
+ args.AppendString(details.url.spec());
+ args.AppendString(details.new_url.spec());
+ args.AppendBoolean(
+ details.resource_type == content::RESOURCE_TYPE_MAIN_FRAME);
+ Emit("did-get-redirect-request", args);
+}
+
bool WebContents::OnMessageReceived(const IPC::Message& message) {
bool handled = true;
IPC_BEGIN_MESSAGE_MAP(WebContents, message)
virtual void RenderProcessGone(base::TerminationStatus status) override;
virtual void DidFinishLoad(content::RenderFrameHost* render_frame_host,
const GURL& validated_url) override;
+ virtual void DidFailLoad(content::RenderFrameHost* render_frame_host,
+ const GURL& validated_url,
+ int error_code,
+ const base::string16& error_description) override;
virtual void DidStartLoading(
content::RenderViewHost* render_view_host) override;
virtual void DidStopLoading(
content::RenderViewHost* render_view_host) override;
+ virtual void DidGetRedirectForResourceRequest(
+ content::RenderViewHost* render_view_host,
+ const content::ResourceRedirectDetails& details) override;
virtual bool OnMessageReceived(const IPC::Message& message) override;
virtual void RenderViewReady() override;
virtual void WebContentsDestroyed() override;
`WebContents` is an
[EventEmitter](http://nodejs.org/api/events.html#events_class_events_eventemitter).
-### Event: 'crashed'
-
-Emitted when the renderer process is crashed.
-
### Event: 'did-finish-load'
Emitted when the navigation is done, i.e. the spinner of the tab will stop
-spinning, and the onload event was dispatched.
+spinning, and the `onload` event was dispatched.
+
+### Event: 'did-fail-load'
+
+* `event` Event
+* `errorCode` Integer
+* `errorDescription` String
+
+This event is like `did-finish-load`, but emitted when the load failed or was
+cancelled, e.g. `window.stop()` is invoked.
### Event: 'did-frame-finish-load'
### Event: 'did-start-loading'
+Corresponds to the points in time when the spinner of the tab starts spinning.
+
### Event: 'did-stop-loading'
+Corresponds to the points in time when the spinner of the tab stops spinning.
+
+### Event: 'did-get-redirect-request'
+
+* `event` Event
+* `oldUrl` String
+* `newUrl` String
+* `isMainFrame` Boolean
+
+Emitted when a redirect was received while requesting a resource.
+
+### Event: 'crashed'
+
+Emitted when the renderer process is crashed.
+
+### Event: 'destroyed'
+
+Emitted when the WebContents is destroyed.
+
### WebContents.loadUrl(url)
* `url` URL