Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1427)

Unified Diff: Source/web/WebViewImpl.cpp

Issue 23506013: Make the embedder responsible for creating the WebFrame (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fix lifetime on frame detach Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/web/WebViewImpl.h ('k') | Source/web/tests/AssociatedURLLoaderTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/web/WebViewImpl.cpp
diff --git a/Source/web/WebViewImpl.cpp b/Source/web/WebViewImpl.cpp
index 9b391cec8c9f0540418c969ed2b2ad10b806c74f..2f80ca697929d4cc7c9ce6cf68c4565e441dec29 100644
--- a/Source/web/WebViewImpl.cpp
+++ b/Source/web/WebViewImpl.cpp
@@ -271,6 +271,12 @@ static int webInputEventKeyStateToPlatformEventKeyState(int webInputEventKeyStat
WebView* WebView::create(WebViewClient* client)
{
// Pass the WebViewImpl's self-reference to the caller.
+ return WebViewImpl::create(client);
+}
+
+WebViewImpl* WebViewImpl::create(WebViewClient* client)
+{
+ // Pass the WebViewImpl's self-reference to the caller.
return adoptRef(new WebViewImpl(client)).leakRef();
}
@@ -314,18 +320,27 @@ void WebView::didExitModalLoop()
pageGroupLoadDeferrerStack().removeLast();
}
-void WebViewImpl::initializeMainFrame(WebFrameClient* frameClient)
+void WebViewImpl::setMainFrame(WebFrame* frame)
{
- // NOTE: The WebFrameImpl takes a reference to itself within InitMainFrame
- // and releases that reference once the corresponding Frame is destroyed.
- RefPtr<WebFrameImpl> frame = WebFrameImpl::create(frameClient);
-
- frame->initializeAsMainFrame(page());
+ // NOTE: The WebFrameImpl takes a reference to itself within
+ // initializeAsMainFrame() and releases that reference once the
+ // corresponding Frame is destroyed.
+ toWebFrameImpl(frame)->initializeAsMainFrame(page());
}
-void WebViewImpl::initializeHelperPluginFrame(WebFrameClient* client)
+void WebViewImpl::initializeMainFrame(WebFrameClient* frameClient)
{
- RefPtr<WebFrameImpl> frame = WebFrameImpl::create(client);
+ // NOTE: Previously, WebViewImpl was responsible for allocating its own
+ // mainframe. This code is for supporting clients that have yet to move
+ // to setMainFrame(). Though the setMainFrame() accepts a raw pointer, it
+ // implicitly takes a refcount on the frame. Dropping our RefPtr here
+ // will effectively pass ownership to m_page. New users of WebViewImpl
+ // should call WebFrameImpl::create() to construct their own mainframe,
+ // pass it into WebViewImpl::setMainFrame(), keep a pointer to the
+ // mainframe, and call WebFrameImpl::close() on it when closing the
+ // WebViewImpl.
+ RefPtr<WebFrameImpl> frame = adoptRef(WebFrameImpl::create(frameClient));
+ setMainFrame(frame.get());
}
void WebViewImpl::setAutofillClient(WebAutofillClient* autofillClient)
« no previous file with comments | « Source/web/WebViewImpl.h ('k') | Source/web/tests/AssociatedURLLoaderTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698