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

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: wordmith a comment 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
Index: Source/web/WebViewImpl.cpp
diff --git a/Source/web/WebViewImpl.cpp b/Source/web/WebViewImpl.cpp
index 3cd8a54068bd35a1e95930c193eb081fc28904e9..a5767401648726af7d239c11a99e500cd75552b7 100644
--- a/Source/web/WebViewImpl.cpp
+++ b/Source/web/WebViewImpl.cpp
@@ -270,6 +270,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();
}
@@ -313,18 +319,26 @@ 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
darin (slow to review) 2013/09/19 22:36:19 nit: InitMainFrame -> initializeAsMainFrame.
awong 2013/09/20 00:36:24 Done.
// and releases that reference once the corresponding Frame is destroyed.
- RefPtr<WebFrameImpl> frame = WebFrameImpl::create(frameClient);
-
- frame->initializeAsMainFrame(page());
+ static_cast<WebFrameImpl*>(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)

Powered by Google App Engine
This is Rietveld 408576698