diff options
author | alexmos@chromium.org <alexmos@chromium.org> | 2015-08-07 21:54:44 +0000 |
---|---|---|
committer | alexmos@chromium.org <alexmos@chromium.org> | 2015-08-07 21:54:44 +0000 |
commit | 40a4b3f49d7999a249b333ce63db8d3e0d003ff2 (patch) | |
tree | 0ab35e57ebc41d8ed3c6142591a95ab8e3c92ae7 | |
parent | 3a579571b941b8d12094b7a055c435d6622013b2 (diff) | |
download | chromium_src-40a4b3f49d7999a249b333ce63db8d3e0d003ff2.zip chromium_src-40a4b3f49d7999a249b333ce63db8d3e0d003ff2.tar.gz chromium_src-40a4b3f49d7999a249b333ce63db8d3e0d003ff2.tar.bz2 |
Add Blink-side support for forwarding opener updates to browser process.
Currently, the browser process only learns when a frame's opener is
disowned, but not when it's updated via window.open. For example,
when a frame foo executes window.open("", "bar"), the bar frame's
opener is set to foo. This CL prepares Blink to also forward such
opener updates to the browser process.
Note that window.open can update both a LocalFrame's and a
RemoteFrame's opener (unlike disowning, which can only be done for a
LocalFrame), hence the need for both WebFrameClient::didUpdateOpener
and WebRemoteFrameClient::didUpdateOpener. Implementations for both
will come in a later content-side CL. These also will replace the
existing plumbing for disowning openers, which will be done by passing
nullptr to didUpdateOpener.
BUG=225940
Review URL: https://codereview.chromium.org/1279623002
git-svn-id: svn://svn.chromium.org/blink/trunk@200197 bbb929c8-8fbe-4397-9dbb-9b2b20218538
5 files changed, 19 insertions, 3 deletions
diff --git a/third_party/WebKit/Source/web/FrameLoaderClientImpl.cpp b/third_party/WebKit/Source/web/FrameLoaderClientImpl.cpp index 8885c1b..fd0ea17 100644 --- a/third_party/WebKit/Source/web/FrameLoaderClientImpl.cpp +++ b/third_party/WebKit/Source/web/FrameLoaderClientImpl.cpp @@ -278,7 +278,10 @@ Frame* FrameLoaderClientImpl::opener() const void FrameLoaderClientImpl::setOpener(Frame* opener) { - m_webFrame->setOpener(WebFrame::fromFrame(opener)); + WebFrame* openerFrame = WebFrame::fromFrame(opener); + if (m_webFrame->client() && m_webFrame->opener() != openerFrame) + m_webFrame->client()->didChangeOpener(openerFrame); + m_webFrame->setOpener(openerFrame); } Frame* FrameLoaderClientImpl::parent() const diff --git a/third_party/WebKit/Source/web/RemoteFrameClientImpl.cpp b/third_party/WebKit/Source/web/RemoteFrameClientImpl.cpp index c62abde..a8b1f6d 100644 --- a/third_party/WebKit/Source/web/RemoteFrameClientImpl.cpp +++ b/third_party/WebKit/Source/web/RemoteFrameClientImpl.cpp @@ -57,7 +57,10 @@ Frame* RemoteFrameClientImpl::opener() const void RemoteFrameClientImpl::setOpener(Frame* opener) { - m_webFrame->setOpener(WebFrame::fromFrame(opener)); + WebFrame* openerFrame = WebFrame::fromFrame(opener); + if (m_webFrame->client() && m_webFrame->opener() != openerFrame) + m_webFrame->client()->didChangeOpener(openerFrame); + m_webFrame->setOpener(openerFrame); } Frame* RemoteFrameClientImpl::parent() const diff --git a/third_party/WebKit/Source/web/WebLocalFrameImpl.cpp b/third_party/WebKit/Source/web/WebLocalFrameImpl.cpp index 0ecb205..317dbe6 100644 --- a/third_party/WebKit/Source/web/WebLocalFrameImpl.cpp +++ b/third_party/WebKit/Source/web/WebLocalFrameImpl.cpp @@ -741,7 +741,9 @@ WebView* WebLocalFrameImpl::view() const void WebLocalFrameImpl::setOpener(WebFrame* opener) { - // FIXME: Does this need to move up into WebFrame too? + // TODO(alexmos): Remove this once didChangeOpener is implemented in + // content, as all opener updates will go through it, including disowned + // openers. if (WebFrame::opener() && !opener && m_client) m_client->didDisownOpener(this); diff --git a/third_party/WebKit/public/web/WebFrameClient.h b/third_party/WebKit/public/web/WebFrameClient.h index ce2106a..7315757 100644 --- a/third_party/WebKit/public/web/WebFrameClient.h +++ b/third_party/WebKit/public/web/WebFrameClient.h @@ -158,8 +158,13 @@ public: // This frame set its opener to null, disowning it. // See http://html.spec.whatwg.org/#dom-opener. + // TODO(alexmos): Remove this once didChangeOpener is implemented in content. virtual void didDisownOpener(WebLocalFrame*) { } + // This frame has set its opener to another frame, or disowned the opener + // if opener is null. See http://html.spec.whatwg.org/#dom-opener. + virtual void didChangeOpener(WebFrame*) { } + // Specifies the reason for the detachment. enum class DetachType { Remove, Swap }; diff --git a/third_party/WebKit/public/web/WebRemoteFrameClient.h b/third_party/WebKit/public/web/WebRemoteFrameClient.h index 15afdfe..64b15a8 100644 --- a/third_party/WebKit/public/web/WebRemoteFrameClient.h +++ b/third_party/WebKit/public/web/WebRemoteFrameClient.h @@ -43,6 +43,9 @@ public: // FIXME: Remove this method once we have input routing in the browser // process. See http://crbug.com/339659. virtual void forwardInputEvent(const WebInputEvent*) { } + + // This frame updated its opener to another frame. + virtual void didChangeOpener(WebFrame* opener) { } }; } // namespace blink |