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

Unified Diff: content/browser/tab_contents/tab_contents.cc

Issue 7244009: Helper functions for tracking stale TabContentsDelegate's. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Style and destructor Created 9 years, 6 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: content/browser/tab_contents/tab_contents.cc
diff --git a/content/browser/tab_contents/tab_contents.cc b/content/browser/tab_contents/tab_contents.cc
index cc805054f208b971cb56e8f7554f03984c3bdc26..ce69c9777be6cc7bca7af3f6de5e5139fe396eb7 100644
--- a/content/browser/tab_contents/tab_contents.cc
+++ b/content/browser/tab_contents/tab_contents.cc
@@ -217,8 +217,10 @@ TabContents::~TabContents() {
registrar_.RemoveAll();
// Clear out any JavaScript state.
- if (delegate_)
+ if (delegate_) {
delegate_->GetJavaScriptDialogCreator()->ResetJavaScriptState(this);
+ set_delegate(NULL);
sky 2011/06/23 18:51:27 You should do this last. It's possible some of the
cbentzel 2011/06/23 19:09:57 Done.
+ }
NotifyDisconnected();
@@ -623,6 +625,19 @@ void TabContents::AddNewContents(TabContents* new_contents,
user_gesture);
}
+void TabContents::set_delegate(TabContentsDelegate* delegate) {
sky 2011/06/23 18:51:27 Add a TODO about either removing debugging code, o
cbentzel 2011/06/23 19:09:57 Done.
+ if (delegate == delegate_)
cbentzel 2011/06/23 19:09:57 Also, compacted vertical whitespace of set_delegat
+ return;
+
+ if (delegate_)
+ delegate_->Detach(this);
+
+ delegate_ = delegate;
+
+ if (delegate_)
+ delegate_->Attach(this);
+}
+
gfx::NativeView TabContents::GetContentNativeView() const {
return view_->GetContentNativeView();
}

Powered by Google App Engine
This is Rietveld 408576698