diff options
Diffstat (limited to 'src/com/android/browser/Tab.java')
-rw-r--r-- | src/com/android/browser/Tab.java | 38 |
1 files changed, 34 insertions, 4 deletions
diff --git a/src/com/android/browser/Tab.java b/src/com/android/browser/Tab.java index ecd4a80..8bf32b0 100644 --- a/src/com/android/browser/Tab.java +++ b/src/com/android/browser/Tab.java @@ -1412,6 +1412,9 @@ class Tab implements PictureListener { R.dimen.tab_thumbnail_height); updateShouldCaptureThumbnails(); restoreState(state); + if (getId() == -1) { + mId = TabControl.getNextId(); + } setWebView(w); mHandler = new Handler() { @Override @@ -1450,10 +1453,6 @@ class Tab implements PictureListener { updateShouldCaptureThumbnails(); } - public void setId(long id) { - mId = id; - } - public long getId() { return mId; } @@ -1592,6 +1591,9 @@ class Tab implements PictureListener { * Set the parent tab of this tab. */ void setParent(Tab parent) { + if (parent == this) { + throw new IllegalStateException("Cannot set parent to self!"); + } mParent = parent; // This tab may have been freed due to low memory. If that is the case, // the parent tab id is already saved. If we are changing that id @@ -1610,6 +1612,10 @@ class Tab implements PictureListener { != mSettings.hasDesktopUseragent(getWebView())) { mSettings.toggleDesktopUseragent(getWebView()); } + + if (parent != null && parent.getId() == getId()) { + throw new IllegalStateException("Parent has same ID as child!"); + } } /** @@ -1689,6 +1695,7 @@ class Tab implements PictureListener { if (!mInForeground) { return; } + capture(); mInForeground = false; pause(); mMainView.setOnCreateContextMenuListener(null); @@ -2175,4 +2182,27 @@ class Tab implements PictureListener { } }; + @Override + public String toString() { + StringBuilder builder = new StringBuilder(100); + builder.append(mId); + builder.append(") has parent: "); + if (getParent() != null) { + builder.append("true["); + builder.append(getParent().getId()); + builder.append("]"); + } else { + builder.append("false"); + } + builder.append(", incog: "); + builder.append(isPrivateBrowsingEnabled()); + if (!isPrivateBrowsingEnabled()) { + builder.append(", title: "); + builder.append(getTitle()); + builder.append(", url: "); + builder.append(getUrl()); + } + return builder.toString(); + } + } |