diff options
author | twiz@chromium.org <twiz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-30 22:39:22 +0000 |
---|---|---|
committer | twiz@chromium.org <twiz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-30 22:39:22 +0000 |
commit | 16e3d45d6fd4a2203ddb248d636dcd320a3639f0 (patch) | |
tree | a5b9c90129b896ccaa112e5afc4e390adc8e0571 /chrome/browser/renderer_host | |
parent | f325f1e12a828a0a3fa74f75e1b2ea8cb49b0102 (diff) | |
download | chromium_src-16e3d45d6fd4a2203ddb248d636dcd320a3639f0.zip chromium_src-16e3d45d6fd4a2203ddb248d636dcd320a3639f0.tar.gz chromium_src-16e3d45d6fd4a2203ddb248d636dcd320a3639f0.tar.bz2 |
Clean-up of the asynchronous behaviour of the experimental extension popup API.
- It was previously possible to programmatically launch two popups from the same extension. (Simply call popup.show twice in a row, or in a callback chain.)
I removed this incorrect funcationality by registering ExtensionPopupHost to listen for EXTENSION_HOST_CREATED notifications. If a popup is shown, and a new ExtensionHost is constructed of type EXTENSION_POPUP, then the presently displayed popup is dismissed.
- The callback function for popup.show(...) was previously called in response to EXTENSION_POPUP_VIEW_READY, as processed in response to a ViewHostMsg_DocumentAvailableInMainFrame message. This message wassent after PARSING of the conent of the popup view. Because of this behaviour, the API was difficult to use because one could not meaningfully interact with the popup page
during the callback: The callback would race with completion of the onload handler within the popup, so some sort of polling for onload-complete was required.
I fixed the problem by adding new notifications and messages so that EXTENSION_POPUP_VIEW_READY is now sent only after all onload handlers have been invoked.Corresponding unit-tests have also been added.
BUG=None
TEST=ExtensionApiTest.Popup
Review URL: http://codereview.chromium.org/1512007
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@46136 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/renderer_host')
-rw-r--r-- | chrome/browser/renderer_host/render_view_host.cc | 6 | ||||
-rw-r--r-- | chrome/browser/renderer_host/render_view_host.h | 1 | ||||
-rw-r--r-- | chrome/browser/renderer_host/render_view_host_delegate.h | 4 |
3 files changed, 11 insertions, 0 deletions
diff --git a/chrome/browser/renderer_host/render_view_host.cc b/chrome/browser/renderer_host/render_view_host.cc index 0cca1a9..38834ef 100644 --- a/chrome/browser/renderer_host/render_view_host.cc +++ b/chrome/browser/renderer_host/render_view_host.cc @@ -723,6 +723,8 @@ void RenderViewHost::OnMessageReceived(const IPC::Message& msg) { IPC_MESSAGE_HANDLER(ViewHostMsg_DidStopLoading, OnMsgDidStopLoading) IPC_MESSAGE_HANDLER(ViewHostMsg_DocumentAvailableInMainFrame, OnMsgDocumentAvailableInMainFrame) + IPC_MESSAGE_HANDLER(ViewHostMsg_DocumentOnLoadCompletedInMainFrame, + OnMsgDocumentOnLoadCompletedInMainFrame) IPC_MESSAGE_HANDLER(ViewHostMsg_DidLoadResourceFromMemoryCache, OnMsgDidLoadResourceFromMemoryCache) IPC_MESSAGE_HANDLER(ViewHostMsg_DidDisplayInsecureContent, @@ -1051,6 +1053,10 @@ void RenderViewHost::OnMsgDocumentAvailableInMainFrame() { delegate_->DocumentAvailableInMainFrame(this); } +void RenderViewHost::OnMsgDocumentOnLoadCompletedInMainFrame() { + delegate_->DocumentOnLoadCompletedInMainFrame(this); +} + void RenderViewHost::OnMsgDidLoadResourceFromMemoryCache( const GURL& url, const std::string& frame_origin, diff --git a/chrome/browser/renderer_host/render_view_host.h b/chrome/browser/renderer_host/render_view_host.h index b384d6d..ea1ba15 100644 --- a/chrome/browser/renderer_host/render_view_host.h +++ b/chrome/browser/renderer_host/render_view_host.h @@ -497,6 +497,7 @@ class RenderViewHost : public RenderWidgetHost { void OnMsgDidStartLoading(); void OnMsgDidStopLoading(); void OnMsgDocumentAvailableInMainFrame(); + void OnMsgDocumentOnLoadCompletedInMainFrame(); void OnMsgDidLoadResourceFromMemoryCache(const GURL& url, const std::string& frame_origin, const std::string& main_frame_origin, diff --git a/chrome/browser/renderer_host/render_view_host_delegate.h b/chrome/browser/renderer_host/render_view_host_delegate.h index 233099c..b8ca5f0 100644 --- a/chrome/browser/renderer_host/render_view_host_delegate.h +++ b/chrome/browser/renderer_host/render_view_host_delegate.h @@ -537,6 +537,10 @@ class RenderViewHostDelegate { // the document has finished parsing. virtual void DocumentAvailableInMainFrame(RenderViewHost* render_view_host) {} + // The onload handler in the RenderView's main frame has completed. + virtual void DocumentOnLoadCompletedInMainFrame( + RenderViewHost* render_view_host) {} + // The page wants to open a URL with the specified disposition. virtual void RequestOpenURL(const GURL& url, const GURL& referrer, |