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

Unified Diff: webkit/glue/webframe_impl.cc

Issue 99283: Add a BeforeDestroyFrame notification method to WebViewDelegate (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 11 years, 7 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 | « webkit/glue/webframe_impl.h ('k') | webkit/glue/webframeloaderclient_impl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/glue/webframe_impl.cc
===================================================================
--- webkit/glue/webframe_impl.cc (revision 15231)
+++ webkit/glue/webframe_impl.cc (working copy)
@@ -141,6 +141,7 @@
#include "third_party/WebKit/WebKit/chromium/public/WebScriptSource.h"
#include "third_party/WebKit/WebKit/chromium/public/WebSize.h"
#include "webkit/glue/alt_error_page_resource_fetcher.h"
+#include "webkit/glue/chrome_client_impl.h"
#include "webkit/glue/dom_operations.h"
#include "webkit/glue/dom_operations_private.h"
#include "webkit/glue/feed.h"
@@ -381,10 +382,8 @@
// WebFrame -------------------------------------------------------------------
void WebFrameImpl::InitMainFrame(WebViewImpl* webview_impl) {
- webview_impl_ = webview_impl;
-
RefPtr<Frame> frame =
- Frame::create(webview_impl_->page(), 0, &frame_loader_client_);
+ Frame::create(webview_impl->page(), 0, &frame_loader_client_);
frame_ = frame.get();
// Add reference on behalf of FrameLoader. See comments in
@@ -477,7 +476,7 @@
current_item = HistoryItem::create();
current_item->setLastVisitWasFailure(true);
frame_->loader()->setCurrentHistoryItem(current_item);
- webview_impl_->SetCurrentHistoryItem(current_item.get());
+ GetWebViewImpl()->SetCurrentHistoryItem(current_item.get());
}
frame_->loader()->goToItem(request_impl->history_item().get(),
@@ -630,7 +629,7 @@
// only get saved to history when it becomes the previous item. The caller
// is expected to query the history state after a navigation occurs, after
// the desired history item has become the previous entry.
- RefPtr<HistoryItem> item = webview_impl_->GetPreviousHistoryItem();
+ RefPtr<HistoryItem> item = GetWebViewImpl()->GetPreviousHistoryItem();
if (!item)
return false;
@@ -831,7 +830,7 @@
}
WebView* WebFrameImpl::GetView() const {
- return webview_impl_;
+ return GetWebViewImpl();
}
std::string WebFrameImpl::GetSecurityOrigin() const {
@@ -1072,6 +1071,7 @@
int WebFrameImpl::OrdinalOfFirstMatchForFrame(WebFrameImpl* frame) const {
int ordinal = 0;
+ WebViewImpl* web_view = GetWebViewImpl();
WebFrameImpl* const main_frame_impl =
static_cast<WebFrameImpl*>(GetView()->GetMainFrame());
// Iterate from the main frame up to (but not including) |frame| and
@@ -1079,7 +1079,7 @@
for (WebFrameImpl* it = main_frame_impl;
it != frame;
it = static_cast<WebFrameImpl*>(
- webview_impl_->GetNextFrameAfter(it, true))) {
+ web_view->GetNextFrameAfter(it, true))) {
if (it->last_match_count_ > 0)
ordinal += it->last_match_count_;
}
@@ -1526,9 +1526,11 @@
frame_->setView(0);
+ WebViewImpl* web_view = GetWebViewImpl();
+
WebCore::FrameView* view;
if (is_main_frame) {
- IntSize size = webkit_glue::WebSizeToIntSize(webview_impl_->size());
+ IntSize size = webkit_glue::WebSizeToIntSize(web_view->size());
view = new FrameView(frame_, size);
} else {
view = new FrameView(frame_);
@@ -1536,7 +1538,7 @@
frame_->setView(view);
- if (webview_impl_->GetIsTransparent())
+ if (web_view->GetIsTransparent())
view->setTransparent(true);
// TODO(darin): The Mac code has a comment about this possibly being
@@ -1563,6 +1565,19 @@
frame->loader()->client())->webframe();
}
+WebViewImpl* WebFrameImpl::GetWebViewImpl() const {
+ if (!frame_ || !frame_->page())
+ return NULL;
+
+ // There are cases where a Frame may outlive its associated Page. Get the
+ // WebViewImpl by accessing it indirectly through the Frame's Page so that we
+ // don't have to worry about cleaning up the WebFrameImpl -> WebViewImpl
+ // pointer. WebCore already clears the Frame's Page pointer when the Page is
+ // destroyed by the WebViewImpl.
+ return static_cast<ChromeClientImpl*>(
+ frame_->page()->chrome()->client())->webview();
+}
+
// WebFrame --------------------------------------------------------------------
void WebFrameImpl::Layout() {
@@ -1642,7 +1657,6 @@
void WebFrameImpl::Closing() {
alt_error_page_fetcher_.reset();
- webview_impl_ = NULL;
frame_ = NULL;
}
@@ -1671,14 +1685,14 @@
// Make sure we never show errors in view source mode.
SetInViewSourceMode(false);
- WebViewDelegate* delegate = webview_impl_->delegate();
+ WebViewImpl* web_view = GetWebViewImpl();
+ WebViewDelegate* delegate = web_view->delegate();
if (delegate) {
WebErrorImpl web_error(error);
if (was_provisional) {
- delegate->DidFailProvisionalLoadWithError(webview_impl_, web_error,
- this);
+ delegate->DidFailProvisionalLoadWithError(web_view, web_error, this);
} else {
- delegate->DidFailLoadWithError(webview_impl_, web_error, this);
+ delegate->DidFailLoadWithError(web_view, web_error, this);
}
}
}
@@ -1700,7 +1714,7 @@
WebErrorImpl weberror_impl(error);
alt_error_page_fetcher_.reset(
- new AltErrorPageResourceFetcher(webview_impl_, weberror_impl, this,
+ new AltErrorPageResourceFetcher(GetWebViewImpl(), weberror_impl, this,
error_page_url));
}
@@ -1775,7 +1789,6 @@
RefPtr<Frame> child_frame = Frame::create(
frame_->page(), owner_element, &webframe->frame_loader_client_);
webframe->frame_ = child_frame.get();
- webframe->webview_impl_ = webview_impl_;
child_frame->tree()->setName(request.frameName());
« no previous file with comments | « webkit/glue/webframe_impl.h ('k') | webkit/glue/webframeloaderclient_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698