private void removeTabFromContentView(Tab tab) { hideTitleBar(); // Remove the container that contains the main WebView. WebView mainView = tab.getWebView(); View container = tab.getViewContainer(); if (mainView == null) { return; } // Remove the container from the content and then remove the // WebView from the container. This will trigger a focus change // needed by WebView. mainView.setEmbeddedTitleBar(null); FrameLayout wrapper = (FrameLayout) container.findViewById(R.id.webview_wrapper); wrapper.removeView(mainView); mContentView.removeView(container); mUiController.endActionMode(); mUiController.removeSubWindow(tab); ErrorConsoleView errorConsole = tab.getErrorConsole(false); if (errorConsole != null) { mErrorConsoleContainer.removeView(errorConsole); } }