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

Unified Diff: chrome/android/shell/java/src/org/chromium/chrome/shell/TabManager.java

Issue 268703005: Fix TabManager for Chrome Shell so it supports swapping WebContents. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 8 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/android/shell/java/src/org/chromium/chrome/shell/TabManager.java
diff --git a/chrome/android/shell/java/src/org/chromium/chrome/shell/TabManager.java b/chrome/android/shell/java/src/org/chromium/chrome/shell/TabManager.java
index 0032af4c04b743d2e88efc6c8d99d1168d262839..b48a5bd657f56e3aba6ad9d76ed7c1f3d7bddb5d 100644
--- a/chrome/android/shell/java/src/org/chromium/chrome/shell/TabManager.java
+++ b/chrome/android/shell/java/src/org/chromium/chrome/shell/TabManager.java
@@ -11,7 +11,10 @@ import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
+import org.chromium.chrome.browser.EmptyTabObserver;
+import org.chromium.chrome.browser.Tab;
import org.chromium.content.browser.ContentVideoViewClient;
+import org.chromium.content.browser.ContentView;
import org.chromium.content.browser.ContentViewClient;
import org.chromium.content.browser.ContentViewRenderView;
import org.chromium.ui.base.WindowAndroid;
@@ -33,6 +36,7 @@ public class TabManager extends LinearLayout {
private ChromeShellTab mCurrentTab;
private String mStartupUrl = DEFAULT_URL;
+ private ContentView mCurrentContentView;
/**
* @param context The Context the view is running in.
@@ -122,11 +126,24 @@ public class TabManager extends LinearLayout {
}
mCurrentTab = tab;
+ mCurrentContentView = tab.getContentView();
+
+ mCurrentTab.addObserver(new EmptyTabObserver() {
+ @Override
+ public void onContentChanged(Tab tab) {
+ mContentViewHolder.removeView(mCurrentContentView);
+ setupContent(tab);
+ }
+ });
mToolbar.showTab(mCurrentTab);
- mContentViewHolder.addView(mCurrentTab.getContentView());
- mContentViewRenderView.setCurrentContentViewCore(mCurrentTab.getContentViewCore());
- mCurrentTab.getContentView().requestFocus();
- mCurrentTab.getContentViewCore().onShow();
+ setupContent(mCurrentTab);
+ }
+
+ private void setupContent(Tab tab) {
+ mContentViewHolder.addView(tab.getContentView());
+ mContentViewRenderView.setCurrentContentViewCore(tab.getContentViewCore());
+ tab.getContentView().requestFocus();
+ tab.getContentViewCore().onShow();
}
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698