Emit("crashed");
}
+void WebContents::DidFinishLoad(int64 frame_id,
+ const GURL& validated_url,
+ bool is_main_frame,
+ content::RenderViewHost* render_view_host) {
+ Emit("did-finish-load");
+}
+
+void WebContents::DidStartLoading(content::RenderViewHost* render_view_host) {
+ Emit("did-start-loading");
+}
+
+void WebContents::DidStopLoading(content::RenderViewHost* render_view_host) {
+ Emit("did-stop-loading");
+}
+
void WebContents::WebContentsDestroyed(content::WebContents*) {
// The RenderViewDeleted is not called when the WebContents is destroyed
// directly.
// content::WebContentsObserver implementations:
virtual void RenderViewDeleted(content::RenderViewHost*) OVERRIDE;
virtual void RenderProcessGone(base::TerminationStatus status) OVERRIDE;
+ virtual void DidFinishLoad(
+ int64 frame_id,
+ const GURL& validated_url,
+ bool is_main_frame,
+ content::RenderViewHost* render_view_host) OVERRIDE;
+ virtual void DidStartLoading(
+ content::RenderViewHost* render_view_host) OVERRIDE;
+ virtual void DidStopLoading(
+ content::RenderViewHost* render_view_host) OVERRIDE;
virtual void WebContentsDestroyed(content::WebContents*) OVERRIDE;
private:
*prevent_default = Emit("page-title-updated", args);
}
-void Window::OnLoadingStateChanged(bool is_loading) {
- base::ListValue args;
- args.AppendBoolean(is_loading);
- Emit("loading-state-changed", args);
-}
-
void Window::WillCloseWindow(bool* prevent_default) {
*prevent_default = Emit("close");
}
// Implementations of NativeWindowObserver:
virtual void OnPageTitleUpdated(bool* prevent_default,
const std::string& title) OVERRIDE;
- virtual void OnLoadingStateChanged(bool is_loading) OVERRIDE;
virtual void WillCloseWindow(bool* prevent_default) OVERRIDE;
virtual void OnWindowClosed() OVERRIDE;
virtual void OnWindowBlur() OVERRIDE;
BlurWebView();
}
-void NativeWindow::LoadingStateChanged(content::WebContents* source) {
- bool is_loading = source->IsLoading();
- FOR_EACH_OBSERVER(NativeWindowObserver,
- observers_,
- OnLoadingStateChanged(is_loading));
-}
-
void NativeWindow::MoveContents(content::WebContents* source,
const gfx::Rect& pos) {
SetPosition(pos.origin());
virtual bool CanOverscrollContent() const OVERRIDE;
virtual void ActivateContents(content::WebContents* contents) OVERRIDE;
virtual void DeactivateContents(content::WebContents* contents) OVERRIDE;
- virtual void LoadingStateChanged(content::WebContents* source) OVERRIDE;
virtual void MoveContents(content::WebContents* source,
const gfx::Rect& pos) OVERRIDE;
virtual void CloseContents(content::WebContents* source) OVERRIDE;
virtual void OnPageTitleUpdated(bool* prevent_default,
const std::string& title) {}
- // Called when the window is starting or is done loading a page.
- virtual void OnLoadingStateChanged(bool is_loading) {}
-
// Called when the window is gonna closed.
virtual void WillCloseWindow(bool* prevent_default) {}
describe 'BrowserWindow.close()', ->
it 'should emit unload handler', (done) ->
- w.on 'loading-state-changed', (event, isLoading) ->
- if (!isLoading)
- w.close()
+ w.webContents.on 'did-finish-load', ->
+ w.close()
w.on 'closed', ->
test = path.join(fixtures, 'api', 'unload')
content = fs.readFileSync(test)
it 'should emit beforeunload handler', (done) ->
w.on 'onbeforeunload', ->
done()
- w.on 'loading-state-changed', (event, isLoading) ->
- if (!isLoading)
- w.close()
+ w.webContents.on 'did-finish-load', ->
+ w.close()
w.loadUrl 'file://' + path.join(fixtures, 'api', 'beforeunload-false.html')
describe 'window.close()', ->
w.loadUrl 'file://' + path.join(fixtures, 'api', 'close-beforeunload-false.html')
describe 'BrowserWindow.loadUrl(url)', ->
- it 'should emit loading-state-changed event', (done) ->
- count = 0
- w.on 'loading-state-changed', (event, isLoading) ->
- if count == 0
- assert.equal isLoading, true
- else if count == 1
- assert.equal isLoading, false
- done()
- else
- assert false
-
- ++count
+ it 'should emit did-start-loading event', (done) ->
+ w.webContents.on 'did-start-loading', ->
+ done()
w.loadUrl 'about:blank'
describe 'BrowserWindow.focus()', ->