BaseUi.java revision da580634265a0add98d3c16b07103edbe724a5b3
18233facddcc51865d612a919d450db6954aa48e3Michael Kolb/* 28233facddcc51865d612a919d450db6954aa48e3Michael Kolb * Copyright (C) 2010 The Android Open Source Project 38233facddcc51865d612a919d450db6954aa48e3Michael Kolb * 48233facddcc51865d612a919d450db6954aa48e3Michael Kolb * Licensed under the Apache License, Version 2.0 (the "License"); 58233facddcc51865d612a919d450db6954aa48e3Michael Kolb * you may not use this file except in compliance with the License. 68233facddcc51865d612a919d450db6954aa48e3Michael Kolb * You may obtain a copy of the License at 78233facddcc51865d612a919d450db6954aa48e3Michael Kolb * 88233facddcc51865d612a919d450db6954aa48e3Michael Kolb * http://www.apache.org/licenses/LICENSE-2.0 98233facddcc51865d612a919d450db6954aa48e3Michael Kolb * 108233facddcc51865d612a919d450db6954aa48e3Michael Kolb * Unless required by applicable law or agreed to in writing, software 118233facddcc51865d612a919d450db6954aa48e3Michael Kolb * distributed under the License is distributed on an "AS IS" BASIS, 128233facddcc51865d612a919d450db6954aa48e3Michael Kolb * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 138233facddcc51865d612a919d450db6954aa48e3Michael Kolb * See the License for the specific language governing permissions and 148233facddcc51865d612a919d450db6954aa48e3Michael Kolb * limitations under the License. 158233facddcc51865d612a919d450db6954aa48e3Michael Kolb */ 168233facddcc51865d612a919d450db6954aa48e3Michael Kolb 178233facddcc51865d612a919d450db6954aa48e3Michael Kolbpackage com.android.browser; 188233facddcc51865d612a919d450db6954aa48e3Michael Kolb 198233facddcc51865d612a919d450db6954aa48e3Michael Kolbimport android.app.Activity; 2053ed62c0171fdbaecaccfbbb08cbf22cb08d39a5Michael Kolbimport android.content.Context; 21d3e4d5b4ffdf374b836ec9d4d3e315040c8c3779John Reckimport android.content.Intent; 228233facddcc51865d612a919d450db6954aa48e3Michael Kolbimport android.content.res.Configuration; 238233facddcc51865d612a919d450db6954aa48e3Michael Kolbimport android.content.res.Resources; 248233facddcc51865d612a919d450db6954aa48e3Michael Kolbimport android.graphics.Bitmap; 258233facddcc51865d612a919d450db6954aa48e3Michael Kolbimport android.graphics.BitmapFactory; 265a4372f4638f9a1fc5c052d85977fbcc0c4d8c55Michael Kolbimport android.graphics.Color; 275a4372f4638f9a1fc5c052d85977fbcc0c4d8c55Michael Kolbimport android.graphics.drawable.BitmapDrawable; 288233facddcc51865d612a919d450db6954aa48e3Michael Kolbimport android.graphics.drawable.Drawable; 295a4372f4638f9a1fc5c052d85977fbcc0c4d8c55Michael Kolbimport android.graphics.drawable.LayerDrawable; 305a4372f4638f9a1fc5c052d85977fbcc0c4d8c55Michael Kolbimport android.graphics.drawable.PaintDrawable; 318233facddcc51865d612a919d450db6954aa48e3Michael Kolbimport android.os.Bundle; 325d43ce897758b7cb5deadc1203717b965334784cJohn Reckimport android.os.Handler; 335d43ce897758b7cb5deadc1203717b965334784cJohn Reckimport android.os.Message; 348233facddcc51865d612a919d450db6954aa48e3Michael Kolbimport android.text.TextUtils; 358233facddcc51865d612a919d450db6954aa48e3Michael Kolbimport android.view.Gravity; 368233facddcc51865d612a919d450db6954aa48e3Michael Kolbimport android.view.LayoutInflater; 378233facddcc51865d612a919d450db6954aa48e3Michael Kolbimport android.view.Menu; 383ca12750f9b6231b00a1856dcb25c2d2e07e8784Michael Kolbimport android.view.MenuItem; 3931065b1940cb70ad131f20e29ad6250f7d09a290Michael Kolbimport android.view.MotionEvent; 408233facddcc51865d612a919d450db6954aa48e3Michael Kolbimport android.view.View; 411514bb7ed5656316a8dac966cee21653f3c59affMichael Kolbimport android.view.View.OnClickListener; 428233facddcc51865d612a919d450db6954aa48e3Michael Kolbimport android.view.ViewGroup; 431514bb7ed5656316a8dac966cee21653f3c59affMichael Kolbimport android.view.ViewGroup.LayoutParams; 44c5675ad4baf34547770a98c7c0d8dec7f8fb4999Michael Kolbimport android.view.Window; 458233facddcc51865d612a919d450db6954aa48e3Michael Kolbimport android.view.WindowManager; 463a696280cba53eea153c9d5707b236997d193328Michael Kolbimport android.view.inputmethod.InputMethodManager; 478233facddcc51865d612a919d450db6954aa48e3Michael Kolbimport android.webkit.WebChromeClient; 488233facddcc51865d612a919d450db6954aa48e3Michael Kolbimport android.webkit.WebView; 494d2fcaba7fb8eb1723943ac9a10e76d509330bd1Jonathan Dixonimport android.webkit.WebViewClassic; 508233facddcc51865d612a919d450db6954aa48e3Michael Kolbimport android.widget.FrameLayout; 511514bb7ed5656316a8dac966cee21653f3c59affMichael Kolbimport android.widget.ImageButton; 528233facddcc51865d612a919d450db6954aa48e3Michael Kolbimport android.widget.LinearLayout; 538233facddcc51865d612a919d450db6954aa48e3Michael Kolbimport android.widget.Toast; 548233facddcc51865d612a919d450db6954aa48e3Michael Kolb 552466effd6ef97aa17396c214d51f9f19a4760260Steve Blockimport com.android.browser.Tab.SecurityState; 56bf2ec206e8743467961da3e857b07aad6c50cd67John Reckimport com.android.internal.view.menu.MenuBuilder; 57bf2ec206e8743467961da3e857b07aad6c50cd67John Reck 581bf231334fd4bda8dbde5b9a0345c756a213b3a2Michael Kolbimport java.util.List; 591bf231334fd4bda8dbde5b9a0345c756a213b3a2Michael Kolb 608233facddcc51865d612a919d450db6954aa48e3Michael Kolb/** 618233facddcc51865d612a919d450db6954aa48e3Michael Kolb * UI interface definitions 628233facddcc51865d612a919d450db6954aa48e3Michael Kolb */ 63718a24d6c9671fe2da4112a3b5f30fd3939b38e8John Reckpublic abstract class BaseUi implements UI { 648233facddcc51865d612a919d450db6954aa48e3Michael Kolb 658233facddcc51865d612a919d450db6954aa48e3Michael Kolb private static final String LOGTAG = "BaseUi"; 668233facddcc51865d612a919d450db6954aa48e3Michael Kolb 676670653d355fea0ae20dc51f6c693f994c4cbb54Michael Kolb protected static final FrameLayout.LayoutParams COVER_SCREEN_PARAMS = 688233facddcc51865d612a919d450db6954aa48e3Michael Kolb new FrameLayout.LayoutParams( 698233facddcc51865d612a919d450db6954aa48e3Michael Kolb ViewGroup.LayoutParams.MATCH_PARENT, 708233facddcc51865d612a919d450db6954aa48e3Michael Kolb ViewGroup.LayoutParams.MATCH_PARENT); 718233facddcc51865d612a919d450db6954aa48e3Michael Kolb 726670653d355fea0ae20dc51f6c693f994c4cbb54Michael Kolb protected static final FrameLayout.LayoutParams COVER_SCREEN_GRAVITY_CENTER = 738233facddcc51865d612a919d450db6954aa48e3Michael Kolb new FrameLayout.LayoutParams( 748233facddcc51865d612a919d450db6954aa48e3Michael Kolb ViewGroup.LayoutParams.MATCH_PARENT, 758233facddcc51865d612a919d450db6954aa48e3Michael Kolb ViewGroup.LayoutParams.MATCH_PARENT, 768233facddcc51865d612a919d450db6954aa48e3Michael Kolb Gravity.CENTER); 778233facddcc51865d612a919d450db6954aa48e3Michael Kolb 785d43ce897758b7cb5deadc1203717b965334784cJohn Reck private static final int MSG_HIDE_TITLEBAR = 1; 79ef654f1dd80f55609060005342fc4f2cde62990cJohn Reck public static final int HIDE_TITLEBAR_DELAY = 1500; // in ms 805d43ce897758b7cb5deadc1203717b965334784cJohn Reck 818233facddcc51865d612a919d450db6954aa48e3Michael Kolb Activity mActivity; 828233facddcc51865d612a919d450db6954aa48e3Michael Kolb UiController mUiController; 838233facddcc51865d612a919d450db6954aa48e3Michael Kolb TabControl mTabControl; 84377ea31324391e7878f6f5b7a991c74988c18403Michael Kolb protected Tab mActiveTab; 853a696280cba53eea153c9d5707b236997d193328Michael Kolb private InputMethodManager mInputManager; 868233facddcc51865d612a919d450db6954aa48e3Michael Kolb 872466effd6ef97aa17396c214d51f9f19a4760260Steve Block private Drawable mLockIconSecure; 882466effd6ef97aa17396c214d51f9f19a4760260Steve Block private Drawable mLockIconMixed; 895a4372f4638f9a1fc5c052d85977fbcc0c4d8c55Michael Kolb protected Drawable mGenericFavicon; 908233facddcc51865d612a919d450db6954aa48e3Michael Kolb 916670653d355fea0ae20dc51f6c693f994c4cbb54Michael Kolb protected FrameLayout mContentView; 92f205560dacc8a85f0443ca1949a68962404321e8Michael Kolb protected FrameLayout mCustomViewContainer; 9331065b1940cb70ad131f20e29ad6250f7d09a290Michael Kolb protected FrameLayout mFullscreenContainer; 948233facddcc51865d612a919d450db6954aa48e3Michael Kolb 9531065b1940cb70ad131f20e29ad6250f7d09a290Michael Kolb private View mCustomView; 968233facddcc51865d612a919d450db6954aa48e3Michael Kolb private WebChromeClient.CustomViewCallback mCustomViewCallback; 972d4f1e2553dee6bce5a12162ff6d4459babe2512Derek Sollenberger private int mOriginalOrientation; 988233facddcc51865d612a919d450db6954aa48e3Michael Kolb 998233facddcc51865d612a919d450db6954aa48e3Michael Kolb private LinearLayout mErrorConsoleContainer = null; 1008233facddcc51865d612a919d450db6954aa48e3Michael Kolb 101718a24d6c9671fe2da4112a3b5f30fd3939b38e8John Reck private UrlBarAutoShowManager mUrlBarAutoShowManager; 1028233facddcc51865d612a919d450db6954aa48e3Michael Kolb 103718a24d6c9671fe2da4112a3b5f30fd3939b38e8John Reck private Toast mStopToast; 1045a4372f4638f9a1fc5c052d85977fbcc0c4d8c55Michael Kolb 1058233facddcc51865d612a919d450db6954aa48e3Michael Kolb // the default <video> poster 1068233facddcc51865d612a919d450db6954aa48e3Michael Kolb private Bitmap mDefaultVideoPoster; 1078233facddcc51865d612a919d450db6954aa48e3Michael Kolb // the video progress view 1088233facddcc51865d612a919d450db6954aa48e3Michael Kolb private View mVideoProgressView; 1098233facddcc51865d612a919d450db6954aa48e3Michael Kolb 1108233facddcc51865d612a919d450db6954aa48e3Michael Kolb private boolean mActivityPaused; 111bf2ec206e8743467961da3e857b07aad6c50cd67John Reck protected boolean mUseQuickControls; 1120f602f3933dcd88702fdb514b6611e3066ca7a2bJohn Reck protected TitleBar mTitleBar; 1130f602f3933dcd88702fdb514b6611e3066ca7a2bJohn Reck private NavigationBarBase mNavigationBar; 114da580634265a0add98d3c16b07103edbe724a5b3Michael Kolb protected PieControl mPieControl; 1158233facddcc51865d612a919d450db6954aa48e3Michael Kolb 1168233facddcc51865d612a919d450db6954aa48e3Michael Kolb public BaseUi(Activity browser, UiController controller) { 1178233facddcc51865d612a919d450db6954aa48e3Michael Kolb mActivity = browser; 1188233facddcc51865d612a919d450db6954aa48e3Michael Kolb mUiController = controller; 1198233facddcc51865d612a919d450db6954aa48e3Michael Kolb mTabControl = controller.getTabControl(); 1208233facddcc51865d612a919d450db6954aa48e3Michael Kolb Resources res = mActivity.getResources(); 1213a696280cba53eea153c9d5707b236997d193328Michael Kolb mInputManager = (InputMethodManager) 1223a696280cba53eea153c9d5707b236997d193328Michael Kolb browser.getSystemService(Activity.INPUT_METHOD_SERVICE); 1232466effd6ef97aa17396c214d51f9f19a4760260Steve Block mLockIconSecure = res.getDrawable(R.drawable.ic_secure_holo_dark); 1242466effd6ef97aa17396c214d51f9f19a4760260Steve Block mLockIconMixed = res.getDrawable(R.drawable.ic_secure_partial_holo_dark); 1258233facddcc51865d612a919d450db6954aa48e3Michael Kolb FrameLayout frameLayout = (FrameLayout) mActivity.getWindow() 1268233facddcc51865d612a919d450db6954aa48e3Michael Kolb .getDecorView().findViewById(android.R.id.content); 1277c6e1c928ea078034e7eacf32ef5c209138001d9John Reck LayoutInflater.from(mActivity) 1287c6e1c928ea078034e7eacf32ef5c209138001d9John Reck .inflate(R.layout.custom_screen, frameLayout); 1297c6e1c928ea078034e7eacf32ef5c209138001d9John Reck mContentView = (FrameLayout) frameLayout.findViewById( 1308233facddcc51865d612a919d450db6954aa48e3Michael Kolb R.id.main_content); 13153ed62c0171fdbaecaccfbbb08cbf22cb08d39a5Michael Kolb mCustomViewContainer = (FrameLayout) frameLayout.findViewById( 13253ed62c0171fdbaecaccfbbb08cbf22cb08d39a5Michael Kolb R.id.fullscreen_custom_content); 1337c6e1c928ea078034e7eacf32ef5c209138001d9John Reck mErrorConsoleContainer = (LinearLayout) frameLayout 1348233facddcc51865d612a919d450db6954aa48e3Michael Kolb .findViewById(R.id.error_console); 135c38c604eca3bd0620cd9284187aace78455e723dMichael Kolb setFullscreen(BrowserSettings.getInstance().useFullscreen()); 1365a4372f4638f9a1fc5c052d85977fbcc0c4d8c55Michael Kolb mGenericFavicon = res.getDrawable( 1375a4372f4638f9a1fc5c052d85977fbcc0c4d8c55Michael Kolb R.drawable.app_web_browser_sm); 1380f602f3933dcd88702fdb514b6611e3066ca7a2bJohn Reck mTitleBar = new TitleBar(mActivity, mUiController, this, 1390f602f3933dcd88702fdb514b6611e3066ca7a2bJohn Reck mContentView); 1400f602f3933dcd88702fdb514b6611e3066ca7a2bJohn Reck mTitleBar.setProgress(100); 1410f602f3933dcd88702fdb514b6611e3066ca7a2bJohn Reck mNavigationBar = mTitleBar.getNavigationBar(); 142718a24d6c9671fe2da4112a3b5f30fd3939b38e8John Reck mUrlBarAutoShowManager = new UrlBarAutoShowManager(this); 1438233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 1448233facddcc51865d612a919d450db6954aa48e3Michael Kolb 1458233facddcc51865d612a919d450db6954aa48e3Michael Kolb private void cancelStopToast() { 1468233facddcc51865d612a919d450db6954aa48e3Michael Kolb if (mStopToast != null) { 1478233facddcc51865d612a919d450db6954aa48e3Michael Kolb mStopToast.cancel(); 1488233facddcc51865d612a919d450db6954aa48e3Michael Kolb mStopToast = null; 1498233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 1508233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 1518233facddcc51865d612a919d450db6954aa48e3Michael Kolb 1528233facddcc51865d612a919d450db6954aa48e3Michael Kolb // lifecycle 1538233facddcc51865d612a919d450db6954aa48e3Michael Kolb 1548233facddcc51865d612a919d450db6954aa48e3Michael Kolb public void onPause() { 1557a5cf4714453bd982afc662f373d0c38cddfb023Michael Kolb if (isCustomViewShowing()) { 1567a5cf4714453bd982afc662f373d0c38cddfb023Michael Kolb onHideCustomView(); 1577a5cf4714453bd982afc662f373d0c38cddfb023Michael Kolb } 1588233facddcc51865d612a919d450db6954aa48e3Michael Kolb cancelStopToast(); 1598233facddcc51865d612a919d450db6954aa48e3Michael Kolb mActivityPaused = true; 1608233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 1618233facddcc51865d612a919d450db6954aa48e3Michael Kolb 1628233facddcc51865d612a919d450db6954aa48e3Michael Kolb public void onResume() { 1638233facddcc51865d612a919d450db6954aa48e3Michael Kolb mActivityPaused = false; 1642ae6ef7f6c146a5bc3a4c7ef8de56505eb02399eMichael Kolb // check if we exited without setting active tab 1652ae6ef7f6c146a5bc3a4c7ef8de56505eb02399eMichael Kolb // b: 5188145 1661a4625a4fa1f3aae01de5cee5338ee4552edd3e8Michael Kolb final Tab ct = mTabControl.getCurrentTab(); 1671a4625a4fa1f3aae01de5cee5338ee4552edd3e8Michael Kolb if (ct != null) { 1681a4625a4fa1f3aae01de5cee5338ee4552edd3e8Michael Kolb setActiveTab(ct); 1691a4625a4fa1f3aae01de5cee5338ee4552edd3e8Michael Kolb } 1708233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 1718233facddcc51865d612a919d450db6954aa48e3Michael Kolb 1726670653d355fea0ae20dc51f6c693f994c4cbb54Michael Kolb protected boolean isActivityPaused() { 1736670653d355fea0ae20dc51f6c693f994c4cbb54Michael Kolb return mActivityPaused; 1748233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 1758233facddcc51865d612a919d450db6954aa48e3Michael Kolb 1768233facddcc51865d612a919d450db6954aa48e3Michael Kolb public void onConfigurationChanged(Configuration config) { 1778233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 1788233facddcc51865d612a919d450db6954aa48e3Michael Kolb 1790f602f3933dcd88702fdb514b6611e3066ca7a2bJohn Reck public Activity getActivity() { 1800f602f3933dcd88702fdb514b6611e3066ca7a2bJohn Reck return mActivity; 1810f602f3933dcd88702fdb514b6611e3066ca7a2bJohn Reck } 1820f602f3933dcd88702fdb514b6611e3066ca7a2bJohn Reck 1838233facddcc51865d612a919d450db6954aa48e3Michael Kolb // key handling 1848233facddcc51865d612a919d450db6954aa48e3Michael Kolb 1858233facddcc51865d612a919d450db6954aa48e3Michael Kolb @Override 1868233facddcc51865d612a919d450db6954aa48e3Michael Kolb public boolean onBackKey() { 1878233facddcc51865d612a919d450db6954aa48e3Michael Kolb if (mCustomView != null) { 1888233facddcc51865d612a919d450db6954aa48e3Michael Kolb mUiController.hideCustomView(); 1898233facddcc51865d612a919d450db6954aa48e3Michael Kolb return true; 1908233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 1918233facddcc51865d612a919d450db6954aa48e3Michael Kolb return false; 1928233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 1938233facddcc51865d612a919d450db6954aa48e3Michael Kolb 1942814a362c21ac219410d9b54e1bd3e8152b845c7Michael Kolb @Override 1952814a362c21ac219410d9b54e1bd3e8152b845c7Michael Kolb public boolean onMenuKey() { 1962814a362c21ac219410d9b54e1bd3e8152b845c7Michael Kolb return false; 1972814a362c21ac219410d9b54e1bd3e8152b845c7Michael Kolb } 1982814a362c21ac219410d9b54e1bd3e8152b845c7Michael Kolb 199da580634265a0add98d3c16b07103edbe724a5b3Michael Kolb @Override 200da580634265a0add98d3c16b07103edbe724a5b3Michael Kolb public void setUseQuickControls(boolean useQuickControls) { 201da580634265a0add98d3c16b07103edbe724a5b3Michael Kolb mUseQuickControls = useQuickControls; 202da580634265a0add98d3c16b07103edbe724a5b3Michael Kolb mTitleBar.setUseQuickControls(mUseQuickControls); 203da580634265a0add98d3c16b07103edbe724a5b3Michael Kolb if (useQuickControls) { 204da580634265a0add98d3c16b07103edbe724a5b3Michael Kolb mPieControl = new PieControl(mActivity, mUiController, this); 205da580634265a0add98d3c16b07103edbe724a5b3Michael Kolb mPieControl.attachToContainer(mContentView); 206da580634265a0add98d3c16b07103edbe724a5b3Michael Kolb } else { 207da580634265a0add98d3c16b07103edbe724a5b3Michael Kolb if (mPieControl != null) { 208da580634265a0add98d3c16b07103edbe724a5b3Michael Kolb mPieControl.removeFromContainer(mContentView); 209da580634265a0add98d3c16b07103edbe724a5b3Michael Kolb } 210da580634265a0add98d3c16b07103edbe724a5b3Michael Kolb } 211da580634265a0add98d3c16b07103edbe724a5b3Michael Kolb updateUrlBarAutoShowManagerTarget(); 212da580634265a0add98d3c16b07103edbe724a5b3Michael Kolb } 213da580634265a0add98d3c16b07103edbe724a5b3Michael Kolb 21430c714c853a4239e72ab1e238ce2a92472d06ab0John Reck // Tab callbacks 2158233facddcc51865d612a919d450db6954aa48e3Michael Kolb @Override 21630c714c853a4239e72ab1e238ce2a92472d06ab0John Reck public void onTabDataChanged(Tab tab) { 21730c714c853a4239e72ab1e238ce2a92472d06ab0John Reck setUrlTitle(tab); 21830c714c853a4239e72ab1e238ce2a92472d06ab0John Reck setFavicon(tab); 21930c714c853a4239e72ab1e238ce2a92472d06ab0John Reck updateLockIconToLatest(tab); 2205a72f1858c2f73be3558c6cdaa2c84b4c36fa748Michael Kolb updateNavigationState(tab); 221ef654f1dd80f55609060005342fc4f2cde62990cJohn Reck mTitleBar.onTabDataChanged(tab); 222419f6b4136a8fac758e2159f223700b1dfcc20e2John Reck mNavigationBar.onTabDataChanged(tab); 223a53c98902be0f9f959b6af06227254e5ad2130c9Michael Kolb onProgressChanged(tab); 2248233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 2258233facddcc51865d612a919d450db6954aa48e3Michael Kolb 2268233facddcc51865d612a919d450db6954aa48e3Michael Kolb @Override 2274cd97793901e8f5681cf642d0b2684697964a37aLeon Scroggins public void bookmarkedStatusHasChanged(Tab tab) { 22894b7e04932d77d73f348efecf7f2dd6b4ee5e5a1John Reck if (tab.inForeground()) { 22994b7e04932d77d73f348efecf7f2dd6b4ee5e5a1John Reck boolean isBookmark = tab.isBookmarkedSite(); 2300f602f3933dcd88702fdb514b6611e3066ca7a2bJohn Reck mNavigationBar.setCurrentUrlIsBookmark(isBookmark); 23194b7e04932d77d73f348efecf7f2dd6b4ee5e5a1John Reck } 2324cd97793901e8f5681cf642d0b2684697964a37aLeon Scroggins } 2334cd97793901e8f5681cf642d0b2684697964a37aLeon Scroggins 2344cd97793901e8f5681cf642d0b2684697964a37aLeon Scroggins @Override 2358233facddcc51865d612a919d450db6954aa48e3Michael Kolb public void onPageStopped(Tab tab) { 2368233facddcc51865d612a919d450db6954aa48e3Michael Kolb cancelStopToast(); 2378233facddcc51865d612a919d450db6954aa48e3Michael Kolb if (tab.inForeground()) { 2388233facddcc51865d612a919d450db6954aa48e3Michael Kolb mStopToast = Toast 2398233facddcc51865d612a919d450db6954aa48e3Michael Kolb .makeText(mActivity, R.string.stopping, Toast.LENGTH_SHORT); 2408233facddcc51865d612a919d450db6954aa48e3Michael Kolb mStopToast.show(); 2418233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 2428233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 2438233facddcc51865d612a919d450db6954aa48e3Michael Kolb 2448233facddcc51865d612a919d450db6954aa48e3Michael Kolb @Override 2451bf231334fd4bda8dbde5b9a0345c756a213b3a2Michael Kolb public boolean needsRestoreAllTabs() { 246847b532045e3cb117a847ebb956c9919401f332dJohn Reck return true; 2471bf231334fd4bda8dbde5b9a0345c756a213b3a2Michael Kolb } 2481bf231334fd4bda8dbde5b9a0345c756a213b3a2Michael Kolb 2491bf231334fd4bda8dbde5b9a0345c756a213b3a2Michael Kolb @Override 2508233facddcc51865d612a919d450db6954aa48e3Michael Kolb public void addTab(Tab tab) { 2518233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 2528233facddcc51865d612a919d450db6954aa48e3Michael Kolb 2538233facddcc51865d612a919d450db6954aa48e3Michael Kolb @Override 254377ea31324391e7878f6f5b7a991c74988c18403Michael Kolb public void setActiveTab(final Tab tab) { 2557ac63b64e9f127057f93b12fb65400c5a6dee7c4Michael Kolb if (tab == null) return; 2565d43ce897758b7cb5deadc1203717b965334784cJohn Reck mHandler.removeMessages(MSG_HIDE_TITLEBAR); 25777df4568331d527f993f4d69168218ddf5acdddaMichael Kolb if ((tab != mActiveTab) && (mActiveTab != null)) { 25877df4568331d527f993f4d69168218ddf5acdddaMichael Kolb removeTabFromContentView(mActiveTab); 259bf2ec206e8743467961da3e857b07aad6c50cd67John Reck WebView web = mActiveTab.getWebView(); 260bf2ec206e8743467961da3e857b07aad6c50cd67John Reck if (web != null) { 261bf2ec206e8743467961da3e857b07aad6c50cd67John Reck web.setOnTouchListener(null); 262bf2ec206e8743467961da3e857b07aad6c50cd67John Reck } 2638233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 26477df4568331d527f993f4d69168218ddf5acdddaMichael Kolb mActiveTab = tab; 265da580634265a0add98d3c16b07103edbe724a5b3Michael Kolb BrowserWebView web = (BrowserWebView) mActiveTab.getWebView(); 266718a24d6c9671fe2da4112a3b5f30fd3939b38e8John Reck updateUrlBarAutoShowManagerTarget(); 2675d43ce897758b7cb5deadc1203717b965334784cJohn Reck attachTabToContentView(tab); 268da580634265a0add98d3c16b07103edbe724a5b3Michael Kolb if (web != null) { 269da580634265a0add98d3c16b07103edbe724a5b3Michael Kolb // Request focus on the top window. 270da580634265a0add98d3c16b07103edbe724a5b3Michael Kolb if (mUseQuickControls) { 271da580634265a0add98d3c16b07103edbe724a5b3Michael Kolb mPieControl.forceToTop(mContentView); 272da580634265a0add98d3c16b07103edbe724a5b3Michael Kolb web.setTitleBar(null); 273da580634265a0add98d3c16b07103edbe724a5b3Michael Kolb } else { 274da580634265a0add98d3c16b07103edbe724a5b3Michael Kolb web.setTitleBar(mTitleBar); 275da580634265a0add98d3c16b07103edbe724a5b3Michael Kolb mTitleBar.onScrollChanged(); 276da580634265a0add98d3c16b07103edbe724a5b3Michael Kolb } 277da580634265a0add98d3c16b07103edbe724a5b3Michael Kolb } 2784923c22cb79296a9624a599cf8874323cdbc6cbcMichael Kolb mTitleBar.bringToFront(); 279f8963521024f39236388eb8e70835f813bf7f4eeMichael Kolb tab.getTopWindow().requestFocus(); 2808233facddcc51865d612a919d450db6954aa48e3Michael Kolb setShouldShowErrorConsole(tab, mUiController.shouldShowErrorConsole()); 28130c714c853a4239e72ab1e238ce2a92472d06ab0John Reck onTabDataChanged(tab); 28230c714c853a4239e72ab1e238ce2a92472d06ab0John Reck onProgressChanged(tab); 28303b6bc6dc3644e9843f2ff05bca543e546fe3a61Michael Kolb mNavigationBar.setIncognitoMode(tab.isPrivateBrowsingEnabled()); 2849206677e461328f15854c5fcb1366d0e261534c6Patrick Scott updateAutoLogin(tab, false); 2856ac5bfda1a372219e469d965e94899d3b4895e0fJohn Reck if (web != null && web.getVisibleTitleHeight() 2860f602f3933dcd88702fdb514b6611e3066ca7a2bJohn Reck != mTitleBar.getEmbeddedHeight() 2870241e7556501caae1f57d2bdf3677d7e4a619eb0Michael Kolb && !mUseQuickControls) { 2886ac5bfda1a372219e469d965e94899d3b4895e0fJohn Reck showTitleBarForDuration(); 2896ac5bfda1a372219e469d965e94899d3b4895e0fJohn Reck } 2908233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 2918233facddcc51865d612a919d450db6954aa48e3Michael Kolb 292718a24d6c9671fe2da4112a3b5f30fd3939b38e8John Reck protected void updateUrlBarAutoShowManagerTarget() { 293718a24d6c9671fe2da4112a3b5f30fd3939b38e8John Reck WebView web = mActiveTab != null ? mActiveTab.getWebView() : null; 294718a24d6c9671fe2da4112a3b5f30fd3939b38e8John Reck if (!mUseQuickControls && web instanceof BrowserWebView) { 295718a24d6c9671fe2da4112a3b5f30fd3939b38e8John Reck mUrlBarAutoShowManager.setTarget((BrowserWebView) web); 296718a24d6c9671fe2da4112a3b5f30fd3939b38e8John Reck } else { 297718a24d6c9671fe2da4112a3b5f30fd3939b38e8John Reck mUrlBarAutoShowManager.setTarget(null); 298718a24d6c9671fe2da4112a3b5f30fd3939b38e8John Reck } 299718a24d6c9671fe2da4112a3b5f30fd3939b38e8John Reck } 300718a24d6c9671fe2da4112a3b5f30fd3939b38e8John Reck 301cfa3af5c59abb38c895416a80ef16da0ec1b5287Michael Kolb Tab getActiveTab() { 302cfa3af5c59abb38c895416a80ef16da0ec1b5287Michael Kolb return mActiveTab; 303cfa3af5c59abb38c895416a80ef16da0ec1b5287Michael Kolb } 304cfa3af5c59abb38c895416a80ef16da0ec1b5287Michael Kolb 3058233facddcc51865d612a919d450db6954aa48e3Michael Kolb @Override 3061bf231334fd4bda8dbde5b9a0345c756a213b3a2Michael Kolb public void updateTabs(List<Tab> tabs) { 3071bf231334fd4bda8dbde5b9a0345c756a213b3a2Michael Kolb } 3081bf231334fd4bda8dbde5b9a0345c756a213b3a2Michael Kolb 3091bf231334fd4bda8dbde5b9a0345c756a213b3a2Michael Kolb @Override 3108233facddcc51865d612a919d450db6954aa48e3Michael Kolb public void removeTab(Tab tab) { 31177df4568331d527f993f4d69168218ddf5acdddaMichael Kolb if (mActiveTab == tab) { 3128233facddcc51865d612a919d450db6954aa48e3Michael Kolb removeTabFromContentView(tab); 31377df4568331d527f993f4d69168218ddf5acdddaMichael Kolb mActiveTab = null; 3148233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 3158233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 3168233facddcc51865d612a919d450db6954aa48e3Michael Kolb 3178233facddcc51865d612a919d450db6954aa48e3Michael Kolb @Override 3188233facddcc51865d612a919d450db6954aa48e3Michael Kolb public void detachTab(Tab tab) { 3198233facddcc51865d612a919d450db6954aa48e3Michael Kolb removeTabFromContentView(tab); 3208233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 3218233facddcc51865d612a919d450db6954aa48e3Michael Kolb 3228233facddcc51865d612a919d450db6954aa48e3Michael Kolb @Override 3238233facddcc51865d612a919d450db6954aa48e3Michael Kolb public void attachTab(Tab tab) { 3248233facddcc51865d612a919d450db6954aa48e3Michael Kolb attachTabToContentView(tab); 3258233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 3268233facddcc51865d612a919d450db6954aa48e3Michael Kolb 327377ea31324391e7878f6f5b7a991c74988c18403Michael Kolb protected void attachTabToContentView(Tab tab) { 328d1e2ccc38a2d5318a4ab06b2349cb43303fd6cebMichael Kolb if ((tab == null) || (tab.getWebView() == null)) { 3298233facddcc51865d612a919d450db6954aa48e3Michael Kolb return; 3308233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 3318233facddcc51865d612a919d450db6954aa48e3Michael Kolb View container = tab.getViewContainer(); 3328233facddcc51865d612a919d450db6954aa48e3Michael Kolb WebView mainView = tab.getWebView(); 3338233facddcc51865d612a919d450db6954aa48e3Michael Kolb // Attach the WebView to the container and then attach the 3348233facddcc51865d612a919d450db6954aa48e3Michael Kolb // container to the content view. 3358233facddcc51865d612a919d450db6954aa48e3Michael Kolb FrameLayout wrapper = 3368233facddcc51865d612a919d450db6954aa48e3Michael Kolb (FrameLayout) container.findViewById(R.id.webview_wrapper); 3378233facddcc51865d612a919d450db6954aa48e3Michael Kolb ViewGroup parent = (ViewGroup) mainView.getParent(); 3388233facddcc51865d612a919d450db6954aa48e3Michael Kolb if (parent != wrapper) { 3398233facddcc51865d612a919d450db6954aa48e3Michael Kolb if (parent != null) { 3408233facddcc51865d612a919d450db6954aa48e3Michael Kolb parent.removeView(mainView); 3418233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 3428233facddcc51865d612a919d450db6954aa48e3Michael Kolb wrapper.addView(mainView); 3438233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 3448233facddcc51865d612a919d450db6954aa48e3Michael Kolb parent = (ViewGroup) container.getParent(); 3458233facddcc51865d612a919d450db6954aa48e3Michael Kolb if (parent != mContentView) { 3468233facddcc51865d612a919d450db6954aa48e3Michael Kolb if (parent != null) { 3478233facddcc51865d612a919d450db6954aa48e3Michael Kolb parent.removeView(container); 3488233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 3498233facddcc51865d612a919d450db6954aa48e3Michael Kolb mContentView.addView(container, COVER_SCREEN_PARAMS); 3508233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 3518233facddcc51865d612a919d450db6954aa48e3Michael Kolb mUiController.attachSubWindow(tab); 3528233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 3538233facddcc51865d612a919d450db6954aa48e3Michael Kolb 3548233facddcc51865d612a919d450db6954aa48e3Michael Kolb private void removeTabFromContentView(Tab tab) { 3557cdc4906fc5852297a9a254c3251ad2f4dead6eeMichael Kolb hideTitleBar(); 3568233facddcc51865d612a919d450db6954aa48e3Michael Kolb // Remove the container that contains the main WebView. 3578233facddcc51865d612a919d450db6954aa48e3Michael Kolb WebView mainView = tab.getWebView(); 3588233facddcc51865d612a919d450db6954aa48e3Michael Kolb View container = tab.getViewContainer(); 3598233facddcc51865d612a919d450db6954aa48e3Michael Kolb if (mainView == null) { 3608233facddcc51865d612a919d450db6954aa48e3Michael Kolb return; 3618233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 3628233facddcc51865d612a919d450db6954aa48e3Michael Kolb // Remove the container from the content and then remove the 3638233facddcc51865d612a919d450db6954aa48e3Michael Kolb // WebView from the container. This will trigger a focus change 3648233facddcc51865d612a919d450db6954aa48e3Michael Kolb // needed by WebView. 3658233facddcc51865d612a919d450db6954aa48e3Michael Kolb FrameLayout wrapper = 3668233facddcc51865d612a919d450db6954aa48e3Michael Kolb (FrameLayout) container.findViewById(R.id.webview_wrapper); 3678233facddcc51865d612a919d450db6954aa48e3Michael Kolb wrapper.removeView(mainView); 3688233facddcc51865d612a919d450db6954aa48e3Michael Kolb mContentView.removeView(container); 3698233facddcc51865d612a919d450db6954aa48e3Michael Kolb mUiController.endActionMode(); 3708233facddcc51865d612a919d450db6954aa48e3Michael Kolb mUiController.removeSubWindow(tab); 3718233facddcc51865d612a919d450db6954aa48e3Michael Kolb ErrorConsoleView errorConsole = tab.getErrorConsole(false); 3728233facddcc51865d612a919d450db6954aa48e3Michael Kolb if (errorConsole != null) { 3738233facddcc51865d612a919d450db6954aa48e3Michael Kolb mErrorConsoleContainer.removeView(errorConsole); 3748233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 3758233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 3768233facddcc51865d612a919d450db6954aa48e3Michael Kolb 377a713ec8cc9da6c0c8078cd297c6240eb8bf01bbbMichael Kolb @Override 378a713ec8cc9da6c0c8078cd297c6240eb8bf01bbbMichael Kolb public void onSetWebView(Tab tab, WebView webView) { 379a713ec8cc9da6c0c8078cd297c6240eb8bf01bbbMichael Kolb View container = tab.getViewContainer(); 380a713ec8cc9da6c0c8078cd297c6240eb8bf01bbbMichael Kolb if (container == null) { 381a713ec8cc9da6c0c8078cd297c6240eb8bf01bbbMichael Kolb // The tab consists of a container view, which contains the main 382a713ec8cc9da6c0c8078cd297c6240eb8bf01bbbMichael Kolb // WebView, as well as any other UI elements associated with the tab. 383a713ec8cc9da6c0c8078cd297c6240eb8bf01bbbMichael Kolb container = mActivity.getLayoutInflater().inflate(R.layout.tab, 3847c6e1c928ea078034e7eacf32ef5c209138001d9John Reck mContentView, false); 385a713ec8cc9da6c0c8078cd297c6240eb8bf01bbbMichael Kolb tab.setViewContainer(container); 386a713ec8cc9da6c0c8078cd297c6240eb8bf01bbbMichael Kolb } 387a713ec8cc9da6c0c8078cd297c6240eb8bf01bbbMichael Kolb if (tab.getWebView() != webView) { 388a713ec8cc9da6c0c8078cd297c6240eb8bf01bbbMichael Kolb // Just remove the old one. 389a713ec8cc9da6c0c8078cd297c6240eb8bf01bbbMichael Kolb FrameLayout wrapper = 390a713ec8cc9da6c0c8078cd297c6240eb8bf01bbbMichael Kolb (FrameLayout) container.findViewById(R.id.webview_wrapper); 391a713ec8cc9da6c0c8078cd297c6240eb8bf01bbbMichael Kolb wrapper.removeView(tab.getWebView()); 392a713ec8cc9da6c0c8078cd297c6240eb8bf01bbbMichael Kolb } 393a713ec8cc9da6c0c8078cd297c6240eb8bf01bbbMichael Kolb } 394a713ec8cc9da6c0c8078cd297c6240eb8bf01bbbMichael Kolb 3958233facddcc51865d612a919d450db6954aa48e3Michael Kolb /** 3961514bb7ed5656316a8dac966cee21653f3c59affMichael Kolb * create a sub window container and webview for the tab 3971514bb7ed5656316a8dac966cee21653f3c59affMichael Kolb * Note: this methods operates through side-effects for now 3981514bb7ed5656316a8dac966cee21653f3c59affMichael Kolb * it sets both the subView and subViewContainer for the given tab 3991514bb7ed5656316a8dac966cee21653f3c59affMichael Kolb * @param tab tab to create the sub window for 4001514bb7ed5656316a8dac966cee21653f3c59affMichael Kolb * @param subView webview to be set as a subwindow for the tab 4011514bb7ed5656316a8dac966cee21653f3c59affMichael Kolb */ 4021514bb7ed5656316a8dac966cee21653f3c59affMichael Kolb @Override 4031514bb7ed5656316a8dac966cee21653f3c59affMichael Kolb public void createSubWindow(Tab tab, WebView subView) { 4041514bb7ed5656316a8dac966cee21653f3c59affMichael Kolb View subViewContainer = mActivity.getLayoutInflater().inflate( 4051514bb7ed5656316a8dac966cee21653f3c59affMichael Kolb R.layout.browser_subwindow, null); 4061514bb7ed5656316a8dac966cee21653f3c59affMichael Kolb ViewGroup inner = (ViewGroup) subViewContainer 4071514bb7ed5656316a8dac966cee21653f3c59affMichael Kolb .findViewById(R.id.inner_container); 4081514bb7ed5656316a8dac966cee21653f3c59affMichael Kolb inner.addView(subView, new LayoutParams(LayoutParams.MATCH_PARENT, 4091514bb7ed5656316a8dac966cee21653f3c59affMichael Kolb LayoutParams.MATCH_PARENT)); 4101514bb7ed5656316a8dac966cee21653f3c59affMichael Kolb final ImageButton cancel = (ImageButton) subViewContainer 4111514bb7ed5656316a8dac966cee21653f3c59affMichael Kolb .findViewById(R.id.subwindow_close); 4121514bb7ed5656316a8dac966cee21653f3c59affMichael Kolb final WebView cancelSubView = subView; 4131514bb7ed5656316a8dac966cee21653f3c59affMichael Kolb cancel.setOnClickListener(new OnClickListener() { 4141514bb7ed5656316a8dac966cee21653f3c59affMichael Kolb public void onClick(View v) { 4154d2fcaba7fb8eb1723943ac9a10e76d509330bd1Jonathan Dixon WebViewClassic.fromWebView(cancelSubView).getWebChromeClient().onCloseWindow( 4164d2fcaba7fb8eb1723943ac9a10e76d509330bd1Jonathan Dixon cancelSubView); 4171514bb7ed5656316a8dac966cee21653f3c59affMichael Kolb } 4181514bb7ed5656316a8dac966cee21653f3c59affMichael Kolb }); 4191514bb7ed5656316a8dac966cee21653f3c59affMichael Kolb tab.setSubWebView(subView); 4201514bb7ed5656316a8dac966cee21653f3c59affMichael Kolb tab.setSubViewContainer(subViewContainer); 4211514bb7ed5656316a8dac966cee21653f3c59affMichael Kolb } 4221514bb7ed5656316a8dac966cee21653f3c59affMichael Kolb 4231514bb7ed5656316a8dac966cee21653f3c59affMichael Kolb /** 4248233facddcc51865d612a919d450db6954aa48e3Michael Kolb * Remove the sub window from the content view. 4258233facddcc51865d612a919d450db6954aa48e3Michael Kolb */ 4268233facddcc51865d612a919d450db6954aa48e3Michael Kolb @Override 4278233facddcc51865d612a919d450db6954aa48e3Michael Kolb public void removeSubWindow(View subviewContainer) { 4288233facddcc51865d612a919d450db6954aa48e3Michael Kolb mContentView.removeView(subviewContainer); 4298233facddcc51865d612a919d450db6954aa48e3Michael Kolb mUiController.endActionMode(); 4308233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 4318233facddcc51865d612a919d450db6954aa48e3Michael Kolb 4328233facddcc51865d612a919d450db6954aa48e3Michael Kolb /** 4338233facddcc51865d612a919d450db6954aa48e3Michael Kolb * Attach the sub window to the content view. 4348233facddcc51865d612a919d450db6954aa48e3Michael Kolb */ 4358233facddcc51865d612a919d450db6954aa48e3Michael Kolb @Override 4368233facddcc51865d612a919d450db6954aa48e3Michael Kolb public void attachSubWindow(View container) { 4371514bb7ed5656316a8dac966cee21653f3c59affMichael Kolb if (container.getParent() != null) { 4381514bb7ed5656316a8dac966cee21653f3c59affMichael Kolb // already attached, remove first 4391514bb7ed5656316a8dac966cee21653f3c59affMichael Kolb ((ViewGroup) container.getParent()).removeView(container); 4401514bb7ed5656316a8dac966cee21653f3c59affMichael Kolb } 4418233facddcc51865d612a919d450db6954aa48e3Michael Kolb mContentView.addView(container, COVER_SCREEN_PARAMS); 4428233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 4438233facddcc51865d612a919d450db6954aa48e3Michael Kolb 44411d1978d8d16004598347abc93918b54a5ef760bMichael Kolb protected void refreshWebView() { 44546f987eca738a36e2c8382aaec6c7ef2ae2482aeMichael Kolb WebView web = getWebView(); 44646f987eca738a36e2c8382aaec6c7ef2ae2482aeMichael Kolb if (web != null) { 44746f987eca738a36e2c8382aaec6c7ef2ae2482aeMichael Kolb web.invalidate(); 44846f987eca738a36e2c8382aaec6c7ef2ae2482aeMichael Kolb } 44946f987eca738a36e2c8382aaec6c7ef2ae2482aeMichael Kolb } 45046f987eca738a36e2c8382aaec6c7ef2ae2482aeMichael Kolb 45146f987eca738a36e2c8382aaec6c7ef2ae2482aeMichael Kolb public void editUrl(boolean clearInput) { 45246f987eca738a36e2c8382aaec6c7ef2ae2482aeMichael Kolb if (mUiController.isInCustomActionMode()) { 45346f987eca738a36e2c8382aaec6c7ef2ae2482aeMichael Kolb mUiController.endActionMode(); 45411d1978d8d16004598347abc93918b54a5ef760bMichael Kolb } 45546f987eca738a36e2c8382aaec6c7ef2ae2482aeMichael Kolb showTitleBar(); 456ace2ff88b860c60c634d6cd49177eb4c5413228bMichael Kolb if ((getActiveTab() != null) && !getActiveTab().isSnapshot()) { 457ef654f1dd80f55609060005342fc4f2cde62990cJohn Reck mNavigationBar.startEditingUrl(clearInput); 458ef654f1dd80f55609060005342fc4f2cde62990cJohn Reck } 45911d1978d8d16004598347abc93918b54a5ef760bMichael Kolb } 46011d1978d8d16004598347abc93918b54a5ef760bMichael Kolb 4617cdc4906fc5852297a9a254c3251ad2f4dead6eeMichael Kolb boolean canShowTitleBar() { 4627cdc4906fc5852297a9a254c3251ad2f4dead6eeMichael Kolb return !isTitleBarShowing() 4637cdc4906fc5852297a9a254c3251ad2f4dead6eeMichael Kolb && !isActivityPaused() 4647cdc4906fc5852297a9a254c3251ad2f4dead6eeMichael Kolb && (getActiveTab() != null) 46546f987eca738a36e2c8382aaec6c7ef2ae2482aeMichael Kolb && (getWebView() != null) 4667cdc4906fc5852297a9a254c3251ad2f4dead6eeMichael Kolb && !mUiController.isInCustomActionMode(); 4678233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 4688233facddcc51865d612a919d450db6954aa48e3Michael Kolb 4690f602f3933dcd88702fdb514b6611e3066ca7a2bJohn Reck protected void showTitleBar() { 470ef654f1dd80f55609060005342fc4f2cde62990cJohn Reck mHandler.removeMessages(MSG_HIDE_TITLEBAR); 47146f987eca738a36e2c8382aaec6c7ef2ae2482aeMichael Kolb if (canShowTitleBar()) { 4720f602f3933dcd88702fdb514b6611e3066ca7a2bJohn Reck mTitleBar.show(); 47346f987eca738a36e2c8382aaec6c7ef2ae2482aeMichael Kolb } 4747cdc4906fc5852297a9a254c3251ad2f4dead6eeMichael Kolb } 4756670653d355fea0ae20dc51f6c693f994c4cbb54Michael Kolb 4767cdc4906fc5852297a9a254c3251ad2f4dead6eeMichael Kolb protected void hideTitleBar() { 4770f602f3933dcd88702fdb514b6611e3066ca7a2bJohn Reck if (mTitleBar.isShowing()) { 4780f602f3933dcd88702fdb514b6611e3066ca7a2bJohn Reck mTitleBar.hide(); 47946f987eca738a36e2c8382aaec6c7ef2ae2482aeMichael Kolb } 4807cdc4906fc5852297a9a254c3251ad2f4dead6eeMichael Kolb } 4816670653d355fea0ae20dc51f6c693f994c4cbb54Michael Kolb 4827cdc4906fc5852297a9a254c3251ad2f4dead6eeMichael Kolb protected boolean isTitleBarShowing() { 4830f602f3933dcd88702fdb514b6611e3066ca7a2bJohn Reck return mTitleBar.isShowing(); 4847cdc4906fc5852297a9a254c3251ad2f4dead6eeMichael Kolb } 4856670653d355fea0ae20dc51f6c693f994c4cbb54Michael Kolb 4865d43ce897758b7cb5deadc1203717b965334784cJohn Reck public boolean isEditingUrl() { 4870f602f3933dcd88702fdb514b6611e3066ca7a2bJohn Reck return mTitleBar.isEditingUrl(); 4885d43ce897758b7cb5deadc1203717b965334784cJohn Reck } 4895d43ce897758b7cb5deadc1203717b965334784cJohn Reck 49080f750852edf43c6b09e5633f2c6ebdb2ed94a5bMichael Kolb public void stopEditingUrl() { 49180f750852edf43c6b09e5633f2c6ebdb2ed94a5bMichael Kolb mTitleBar.getNavigationBar().stopEditingUrl(); 49280f750852edf43c6b09e5633f2c6ebdb2ed94a5bMichael Kolb } 49380f750852edf43c6b09e5633f2c6ebdb2ed94a5bMichael Kolb 4940f602f3933dcd88702fdb514b6611e3066ca7a2bJohn Reck public TitleBar getTitleBar() { 4950f602f3933dcd88702fdb514b6611e3066ca7a2bJohn Reck return mTitleBar; 4960f602f3933dcd88702fdb514b6611e3066ca7a2bJohn Reck } 4976670653d355fea0ae20dc51f6c693f994c4cbb54Michael Kolb 4986670653d355fea0ae20dc51f6c693f994c4cbb54Michael Kolb @Override 49911d1978d8d16004598347abc93918b54a5ef760bMichael Kolb public void showVoiceTitleBar(String title, List<String> results) { 5000f602f3933dcd88702fdb514b6611e3066ca7a2bJohn Reck mNavigationBar.setInVoiceMode(true, results); 5010f602f3933dcd88702fdb514b6611e3066ca7a2bJohn Reck mNavigationBar.setDisplayTitle(title); 5028233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 5038233facddcc51865d612a919d450db6954aa48e3Michael Kolb 5046670653d355fea0ae20dc51f6c693f994c4cbb54Michael Kolb @Override 5056670653d355fea0ae20dc51f6c693f994c4cbb54Michael Kolb public void revertVoiceTitleBar(Tab tab) { 5060f602f3933dcd88702fdb514b6611e3066ca7a2bJohn Reck mNavigationBar.setInVoiceMode(false, null); 50730c714c853a4239e72ab1e238ce2a92472d06ab0John Reck String url = tab.getUrl(); 5080f602f3933dcd88702fdb514b6611e3066ca7a2bJohn Reck mNavigationBar.setDisplayTitle(url); 5098233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 5108233facddcc51865d612a919d450db6954aa48e3Michael Kolb 5118233facddcc51865d612a919d450db6954aa48e3Michael Kolb @Override 5122bc8042224be51966d748b870768ec1b376a1621John Reck public void showComboView(ComboViews startingView, Bundle extras) { 513d3e4d5b4ffdf374b836ec9d4d3e315040c8c3779John Reck Intent intent = new Intent(mActivity, ComboViewActivity.class); 514d3e4d5b4ffdf374b836ec9d4d3e315040c8c3779John Reck intent.putExtra(ComboViewActivity.EXTRA_INITIAL_VIEW, startingView.name()); 515d3e4d5b4ffdf374b836ec9d4d3e315040c8c3779John Reck intent.putExtra(ComboViewActivity.EXTRA_COMBO_ARGS, extras); 516d3e4d5b4ffdf374b836ec9d4d3e315040c8c3779John Reck Tab t = getActiveTab(); 517d3e4d5b4ffdf374b836ec9d4d3e315040c8c3779John Reck if (t != null) { 518d3e4d5b4ffdf374b836ec9d4d3e315040c8c3779John Reck intent.putExtra(ComboViewActivity.EXTRA_CURRENT_URL, t.getUrl()); 5193a696280cba53eea153c9d5707b236997d193328Michael Kolb } 520d3e4d5b4ffdf374b836ec9d4d3e315040c8c3779John Reck mActivity.startActivityForResult(intent, Controller.COMBO_VIEW); 5218233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 5228233facddcc51865d612a919d450db6954aa48e3Michael Kolb 5238233facddcc51865d612a919d450db6954aa48e3Michael Kolb @Override 5242d4f1e2553dee6bce5a12162ff6d4459babe2512Derek Sollenberger public void showCustomView(View view, int requestedOrientation, 5258233facddcc51865d612a919d450db6954aa48e3Michael Kolb WebChromeClient.CustomViewCallback callback) { 5268233facddcc51865d612a919d450db6954aa48e3Michael Kolb // if a view already exists then immediately terminate the new one 5278233facddcc51865d612a919d450db6954aa48e3Michael Kolb if (mCustomView != null) { 5288233facddcc51865d612a919d450db6954aa48e3Michael Kolb callback.onCustomViewHidden(); 5298233facddcc51865d612a919d450db6954aa48e3Michael Kolb return; 5308233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 5318233facddcc51865d612a919d450db6954aa48e3Michael Kolb 5322d4f1e2553dee6bce5a12162ff6d4459babe2512Derek Sollenberger mOriginalOrientation = mActivity.getRequestedOrientation(); 53331065b1940cb70ad131f20e29ad6250f7d09a290Michael Kolb FrameLayout decor = (FrameLayout) mActivity.getWindow().getDecorView(); 53431065b1940cb70ad131f20e29ad6250f7d09a290Michael Kolb mFullscreenContainer = new FullscreenHolder(mActivity); 53531065b1940cb70ad131f20e29ad6250f7d09a290Michael Kolb mFullscreenContainer.addView(view, COVER_SCREEN_PARAMS); 53631065b1940cb70ad131f20e29ad6250f7d09a290Michael Kolb decor.addView(mFullscreenContainer, COVER_SCREEN_PARAMS); 53731065b1940cb70ad131f20e29ad6250f7d09a290Michael Kolb mCustomView = view; 538c5675ad4baf34547770a98c7c0d8dec7f8fb4999Michael Kolb setFullscreen(true); 5398233facddcc51865d612a919d450db6954aa48e3Michael Kolb mCustomViewCallback = callback; 5402d4f1e2553dee6bce5a12162ff6d4459babe2512Derek Sollenberger mActivity.setRequestedOrientation(requestedOrientation); 5418233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 5428233facddcc51865d612a919d450db6954aa48e3Michael Kolb 5438233facddcc51865d612a919d450db6954aa48e3Michael Kolb @Override 5448233facddcc51865d612a919d450db6954aa48e3Michael Kolb public void onHideCustomView() { 5458233facddcc51865d612a919d450db6954aa48e3Michael Kolb if (mCustomView == null) 5468233facddcc51865d612a919d450db6954aa48e3Michael Kolb return; 547c5675ad4baf34547770a98c7c0d8dec7f8fb4999Michael Kolb setFullscreen(false); 54831065b1940cb70ad131f20e29ad6250f7d09a290Michael Kolb FrameLayout decor = (FrameLayout) mActivity.getWindow().getDecorView(); 54931065b1940cb70ad131f20e29ad6250f7d09a290Michael Kolb decor.removeView(mFullscreenContainer); 55031065b1940cb70ad131f20e29ad6250f7d09a290Michael Kolb mFullscreenContainer = null; 5518233facddcc51865d612a919d450db6954aa48e3Michael Kolb mCustomView = null; 5528233facddcc51865d612a919d450db6954aa48e3Michael Kolb mCustomViewCallback.onCustomViewHidden(); 5538233facddcc51865d612a919d450db6954aa48e3Michael Kolb // Show the content view. 5542d4f1e2553dee6bce5a12162ff6d4459babe2512Derek Sollenberger mActivity.setRequestedOrientation(mOriginalOrientation); 5558233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 5568233facddcc51865d612a919d450db6954aa48e3Michael Kolb 5578233facddcc51865d612a919d450db6954aa48e3Michael Kolb @Override 5588233facddcc51865d612a919d450db6954aa48e3Michael Kolb public boolean isCustomViewShowing() { 5598233facddcc51865d612a919d450db6954aa48e3Michael Kolb return mCustomView != null; 5608233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 5618233facddcc51865d612a919d450db6954aa48e3Michael Kolb 5626670653d355fea0ae20dc51f6c693f994c4cbb54Michael Kolb protected void dismissIME() { 5633a696280cba53eea153c9d5707b236997d193328Michael Kolb if (mInputManager.isActive()) { 5643a696280cba53eea153c9d5707b236997d193328Michael Kolb mInputManager.hideSoftInputFromWindow(mContentView.getWindowToken(), 5653a696280cba53eea153c9d5707b236997d193328Michael Kolb 0); 5663a696280cba53eea153c9d5707b236997d193328Michael Kolb } 5673a696280cba53eea153c9d5707b236997d193328Michael Kolb } 5683a696280cba53eea153c9d5707b236997d193328Michael Kolb 5696670653d355fea0ae20dc51f6c693f994c4cbb54Michael Kolb @Override 5703ba455394dd3413b6246f00d2bf2083547862735John Reck public boolean isWebShowing() { 571d3e4d5b4ffdf374b836ec9d4d3e315040c8c3779John Reck return mCustomView == null; 5726670653d355fea0ae20dc51f6c693f994c4cbb54Michael Kolb } 5736670653d355fea0ae20dc51f6c693f994c4cbb54Michael Kolb 5749206677e461328f15854c5fcb1366d0e261534c6Patrick Scott @Override 5759206677e461328f15854c5fcb1366d0e261534c6Patrick Scott public void showAutoLogin(Tab tab) { 5769206677e461328f15854c5fcb1366d0e261534c6Patrick Scott updateAutoLogin(tab, true); 5779206677e461328f15854c5fcb1366d0e261534c6Patrick Scott } 5789206677e461328f15854c5fcb1366d0e261534c6Patrick Scott 5799206677e461328f15854c5fcb1366d0e261534c6Patrick Scott @Override 5809206677e461328f15854c5fcb1366d0e261534c6Patrick Scott public void hideAutoLogin(Tab tab) { 5819206677e461328f15854c5fcb1366d0e261534c6Patrick Scott updateAutoLogin(tab, true); 5829206677e461328f15854c5fcb1366d0e261534c6Patrick Scott } 5839206677e461328f15854c5fcb1366d0e261534c6Patrick Scott 5848233facddcc51865d612a919d450db6954aa48e3Michael Kolb // ------------------------------------------------------------------------- 5858233facddcc51865d612a919d450db6954aa48e3Michael Kolb 5865a72f1858c2f73be3558c6cdaa2c84b4c36fa748Michael Kolb protected void updateNavigationState(Tab tab) { 5875a72f1858c2f73be3558c6cdaa2c84b4c36fa748Michael Kolb } 5885a72f1858c2f73be3558c6cdaa2c84b4c36fa748Michael Kolb 58911d1978d8d16004598347abc93918b54a5ef760bMichael Kolb protected void updateAutoLogin(Tab tab, boolean animate) { 5900f602f3933dcd88702fdb514b6611e3066ca7a2bJohn Reck mTitleBar.updateAutoLogin(tab, animate); 59111d1978d8d16004598347abc93918b54a5ef760bMichael Kolb } 5929206677e461328f15854c5fcb1366d0e261534c6Patrick Scott 5938233facddcc51865d612a919d450db6954aa48e3Michael Kolb /** 5948233facddcc51865d612a919d450db6954aa48e3Michael Kolb * Update the lock icon to correspond to our latest state. 5958233facddcc51865d612a919d450db6954aa48e3Michael Kolb */ 5966670653d355fea0ae20dc51f6c693f994c4cbb54Michael Kolb protected void updateLockIconToLatest(Tab t) { 59730c714c853a4239e72ab1e238ce2a92472d06ab0John Reck if (t != null && t.inForeground()) { 5982466effd6ef97aa17396c214d51f9f19a4760260Steve Block updateLockIconImage(t.getSecurityState()); 5998233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 6008233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 6018233facddcc51865d612a919d450db6954aa48e3Michael Kolb 6028233facddcc51865d612a919d450db6954aa48e3Michael Kolb /** 6038233facddcc51865d612a919d450db6954aa48e3Michael Kolb * Updates the lock-icon image in the title-bar. 6048233facddcc51865d612a919d450db6954aa48e3Michael Kolb */ 6052466effd6ef97aa17396c214d51f9f19a4760260Steve Block private void updateLockIconImage(SecurityState securityState) { 6068233facddcc51865d612a919d450db6954aa48e3Michael Kolb Drawable d = null; 6072466effd6ef97aa17396c214d51f9f19a4760260Steve Block if (securityState == SecurityState.SECURITY_STATE_SECURE) { 6082466effd6ef97aa17396c214d51f9f19a4760260Steve Block d = mLockIconSecure; 6094895b0133c337a8d55bf7e9eac64fcecab4e3e79Steve Block } else if (securityState == SecurityState.SECURITY_STATE_MIXED 6104895b0133c337a8d55bf7e9eac64fcecab4e3e79Steve Block || securityState == SecurityState.SECURITY_STATE_BAD_CERTIFICATE) { 6114895b0133c337a8d55bf7e9eac64fcecab4e3e79Steve Block // TODO: It would be good to have different icons for insecure vs mixed content. 6124895b0133c337a8d55bf7e9eac64fcecab4e3e79Steve Block // See http://b/5403800 6132466effd6ef97aa17396c214d51f9f19a4760260Steve Block d = mLockIconMixed; 6148233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 6150f602f3933dcd88702fdb514b6611e3066ca7a2bJohn Reck mNavigationBar.setLock(d); 6168233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 6178233facddcc51865d612a919d450db6954aa48e3Michael Kolb 61830c714c853a4239e72ab1e238ce2a92472d06ab0John Reck protected void setUrlTitle(Tab tab) { 61930c714c853a4239e72ab1e238ce2a92472d06ab0John Reck String url = tab.getUrl(); 62030c714c853a4239e72ab1e238ce2a92472d06ab0John Reck String title = tab.getTitle(); 6216670653d355fea0ae20dc51f6c693f994c4cbb54Michael Kolb if (TextUtils.isEmpty(title)) { 6226670653d355fea0ae20dc51f6c693f994c4cbb54Michael Kolb title = url; 6236670653d355fea0ae20dc51f6c693f994c4cbb54Michael Kolb } 6246670653d355fea0ae20dc51f6c693f994c4cbb54Michael Kolb if (tab.isInVoiceSearchMode()) return; 6256670653d355fea0ae20dc51f6c693f994c4cbb54Michael Kolb if (tab.inForeground()) { 6260f602f3933dcd88702fdb514b6611e3066ca7a2bJohn Reck mNavigationBar.setDisplayTitle(url); 6276670653d355fea0ae20dc51f6c693f994c4cbb54Michael Kolb } 6288233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 6298233facddcc51865d612a919d450db6954aa48e3Michael Kolb 6306670653d355fea0ae20dc51f6c693f994c4cbb54Michael Kolb // Set the favicon in the title bar. 63130c714c853a4239e72ab1e238ce2a92472d06ab0John Reck protected void setFavicon(Tab tab) { 63230c714c853a4239e72ab1e238ce2a92472d06ab0John Reck if (tab.inForeground()) { 63330c714c853a4239e72ab1e238ce2a92472d06ab0John Reck Bitmap icon = tab.getFavicon(); 6340f602f3933dcd88702fdb514b6611e3066ca7a2bJohn Reck mNavigationBar.setFavicon(icon); 63530c714c853a4239e72ab1e238ce2a92472d06ab0John Reck } 6368233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 6378233facddcc51865d612a919d450db6954aa48e3Michael Kolb 6388233facddcc51865d612a919d450db6954aa48e3Michael Kolb @Override 6398233facddcc51865d612a919d450db6954aa48e3Michael Kolb public void onActionModeFinished(boolean inLoad) { 6408233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 6418233facddcc51865d612a919d450db6954aa48e3Michael Kolb 6426670653d355fea0ae20dc51f6c693f994c4cbb54Michael Kolb // active tabs page 6436670653d355fea0ae20dc51f6c693f994c4cbb54Michael Kolb 6446670653d355fea0ae20dc51f6c693f994c4cbb54Michael Kolb public void showActiveTabsPage() { 6456670653d355fea0ae20dc51f6c693f994c4cbb54Michael Kolb } 6466670653d355fea0ae20dc51f6c693f994c4cbb54Michael Kolb 6476670653d355fea0ae20dc51f6c693f994c4cbb54Michael Kolb /** 6486670653d355fea0ae20dc51f6c693f994c4cbb54Michael Kolb * Remove the active tabs page. 6496670653d355fea0ae20dc51f6c693f994c4cbb54Michael Kolb */ 6506670653d355fea0ae20dc51f6c693f994c4cbb54Michael Kolb public void removeActiveTabsPage() { 6516670653d355fea0ae20dc51f6c693f994c4cbb54Michael Kolb } 6526670653d355fea0ae20dc51f6c693f994c4cbb54Michael Kolb 6538233facddcc51865d612a919d450db6954aa48e3Michael Kolb // menu handling callbacks 6548233facddcc51865d612a919d450db6954aa48e3Michael Kolb 6558233facddcc51865d612a919d450db6954aa48e3Michael Kolb @Override 6561acef69ffc079d1bc029ff7eb1f5043f7efd7f36Michael Kolb public boolean onPrepareOptionsMenu(Menu menu) { 6571acef69ffc079d1bc029ff7eb1f5043f7efd7f36Michael Kolb return true; 6581acef69ffc079d1bc029ff7eb1f5043f7efd7f36Michael Kolb } 6591acef69ffc079d1bc029ff7eb1f5043f7efd7f36Michael Kolb 6601acef69ffc079d1bc029ff7eb1f5043f7efd7f36Michael Kolb @Override 6617bdee0b303d8969aace4d3e43be5bb9f16e276bfMichael Kolb public void updateMenuState(Tab tab, Menu menu) { 6627bdee0b303d8969aace4d3e43be5bb9f16e276bfMichael Kolb } 6637bdee0b303d8969aace4d3e43be5bb9f16e276bfMichael Kolb 6647bdee0b303d8969aace4d3e43be5bb9f16e276bfMichael Kolb @Override 6658233facddcc51865d612a919d450db6954aa48e3Michael Kolb public void onOptionsMenuOpened() { 6668233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 6678233facddcc51865d612a919d450db6954aa48e3Michael Kolb 6688233facddcc51865d612a919d450db6954aa48e3Michael Kolb @Override 6698233facddcc51865d612a919d450db6954aa48e3Michael Kolb public void onExtendedMenuOpened() { 6708233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 6718233facddcc51865d612a919d450db6954aa48e3Michael Kolb 6728233facddcc51865d612a919d450db6954aa48e3Michael Kolb @Override 6733ca12750f9b6231b00a1856dcb25c2d2e07e8784Michael Kolb public boolean onOptionsItemSelected(MenuItem item) { 6743ca12750f9b6231b00a1856dcb25c2d2e07e8784Michael Kolb return false; 6753ca12750f9b6231b00a1856dcb25c2d2e07e8784Michael Kolb } 6763ca12750f9b6231b00a1856dcb25c2d2e07e8784Michael Kolb 6773ca12750f9b6231b00a1856dcb25c2d2e07e8784Michael Kolb @Override 6788233facddcc51865d612a919d450db6954aa48e3Michael Kolb public void onOptionsMenuClosed(boolean inLoad) { 6798233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 6808233facddcc51865d612a919d450db6954aa48e3Michael Kolb 6818233facddcc51865d612a919d450db6954aa48e3Michael Kolb @Override 6828233facddcc51865d612a919d450db6954aa48e3Michael Kolb public void onExtendedMenuClosed(boolean inLoad) { 6838233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 6848233facddcc51865d612a919d450db6954aa48e3Michael Kolb 6858233facddcc51865d612a919d450db6954aa48e3Michael Kolb @Override 6868233facddcc51865d612a919d450db6954aa48e3Michael Kolb public void onContextMenuCreated(Menu menu) { 6878233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 6888233facddcc51865d612a919d450db6954aa48e3Michael Kolb 6898233facddcc51865d612a919d450db6954aa48e3Michael Kolb @Override 6908233facddcc51865d612a919d450db6954aa48e3Michael Kolb public void onContextMenuClosed(Menu menu, boolean inLoad) { 6918233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 6928233facddcc51865d612a919d450db6954aa48e3Michael Kolb 6938233facddcc51865d612a919d450db6954aa48e3Michael Kolb // error console 6948233facddcc51865d612a919d450db6954aa48e3Michael Kolb 6958233facddcc51865d612a919d450db6954aa48e3Michael Kolb @Override 6968233facddcc51865d612a919d450db6954aa48e3Michael Kolb public void setShouldShowErrorConsole(Tab tab, boolean flag) { 6979fcefd19ee20ec9f792ddc84be9a871550e82997Michael Kolb if (tab == null) return; 6988233facddcc51865d612a919d450db6954aa48e3Michael Kolb ErrorConsoleView errorConsole = tab.getErrorConsole(true); 6998233facddcc51865d612a919d450db6954aa48e3Michael Kolb if (flag) { 7008233facddcc51865d612a919d450db6954aa48e3Michael Kolb // Setting the show state of the console will cause it's the layout 7018233facddcc51865d612a919d450db6954aa48e3Michael Kolb // to be inflated. 7028233facddcc51865d612a919d450db6954aa48e3Michael Kolb if (errorConsole.numberOfErrors() > 0) { 7038233facddcc51865d612a919d450db6954aa48e3Michael Kolb errorConsole.showConsole(ErrorConsoleView.SHOW_MINIMIZED); 7048233facddcc51865d612a919d450db6954aa48e3Michael Kolb } else { 7058233facddcc51865d612a919d450db6954aa48e3Michael Kolb errorConsole.showConsole(ErrorConsoleView.SHOW_NONE); 7068233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 7078233facddcc51865d612a919d450db6954aa48e3Michael Kolb if (errorConsole.getParent() != null) { 7088233facddcc51865d612a919d450db6954aa48e3Michael Kolb mErrorConsoleContainer.removeView(errorConsole); 7098233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 7108233facddcc51865d612a919d450db6954aa48e3Michael Kolb // Now we can add it to the main view. 7118233facddcc51865d612a919d450db6954aa48e3Michael Kolb mErrorConsoleContainer.addView(errorConsole, 7128233facddcc51865d612a919d450db6954aa48e3Michael Kolb new LinearLayout.LayoutParams( 7138233facddcc51865d612a919d450db6954aa48e3Michael Kolb ViewGroup.LayoutParams.MATCH_PARENT, 7148233facddcc51865d612a919d450db6954aa48e3Michael Kolb ViewGroup.LayoutParams.WRAP_CONTENT)); 7158233facddcc51865d612a919d450db6954aa48e3Michael Kolb } else { 7168233facddcc51865d612a919d450db6954aa48e3Michael Kolb mErrorConsoleContainer.removeView(errorConsole); 7178233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 7188233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 7198233facddcc51865d612a919d450db6954aa48e3Michael Kolb 7208233facddcc51865d612a919d450db6954aa48e3Michael Kolb // ------------------------------------------------------------------------- 7218233facddcc51865d612a919d450db6954aa48e3Michael Kolb // Helper function for WebChromeClient 7228233facddcc51865d612a919d450db6954aa48e3Michael Kolb // ------------------------------------------------------------------------- 7238233facddcc51865d612a919d450db6954aa48e3Michael Kolb 7248233facddcc51865d612a919d450db6954aa48e3Michael Kolb @Override 7258233facddcc51865d612a919d450db6954aa48e3Michael Kolb public Bitmap getDefaultVideoPoster() { 7268233facddcc51865d612a919d450db6954aa48e3Michael Kolb if (mDefaultVideoPoster == null) { 7278233facddcc51865d612a919d450db6954aa48e3Michael Kolb mDefaultVideoPoster = BitmapFactory.decodeResource( 7288233facddcc51865d612a919d450db6954aa48e3Michael Kolb mActivity.getResources(), R.drawable.default_video_poster); 7298233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 7308233facddcc51865d612a919d450db6954aa48e3Michael Kolb return mDefaultVideoPoster; 7318233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 7328233facddcc51865d612a919d450db6954aa48e3Michael Kolb 7338233facddcc51865d612a919d450db6954aa48e3Michael Kolb @Override 7348233facddcc51865d612a919d450db6954aa48e3Michael Kolb public View getVideoLoadingProgressView() { 7358233facddcc51865d612a919d450db6954aa48e3Michael Kolb if (mVideoProgressView == null) { 7368233facddcc51865d612a919d450db6954aa48e3Michael Kolb LayoutInflater inflater = LayoutInflater.from(mActivity); 7378233facddcc51865d612a919d450db6954aa48e3Michael Kolb mVideoProgressView = inflater.inflate( 7388233facddcc51865d612a919d450db6954aa48e3Michael Kolb R.layout.video_loading_progress, null); 7398233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 7408233facddcc51865d612a919d450db6954aa48e3Michael Kolb return mVideoProgressView; 7418233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 7428233facddcc51865d612a919d450db6954aa48e3Michael Kolb 743843510fb4f36a9a834c69d8773156db20ca3d740Michael Kolb @Override 744843510fb4f36a9a834c69d8773156db20ca3d740Michael Kolb public void showMaxTabsWarning() { 745843510fb4f36a9a834c69d8773156db20ca3d740Michael Kolb Toast warning = Toast.makeText(mActivity, 746843510fb4f36a9a834c69d8773156db20ca3d740Michael Kolb mActivity.getString(R.string.max_tabs_warning), 747843510fb4f36a9a834c69d8773156db20ca3d740Michael Kolb Toast.LENGTH_SHORT); 748843510fb4f36a9a834c69d8773156db20ca3d740Michael Kolb warning.show(); 749843510fb4f36a9a834c69d8773156db20ca3d740Michael Kolb } 750843510fb4f36a9a834c69d8773156db20ca3d740Michael Kolb 75146f987eca738a36e2c8382aaec6c7ef2ae2482aeMichael Kolb protected WebView getWebView() { 75246f987eca738a36e2c8382aaec6c7ef2ae2482aeMichael Kolb if (mActiveTab != null) { 75346f987eca738a36e2c8382aaec6c7ef2ae2482aeMichael Kolb return mActiveTab.getWebView(); 75446f987eca738a36e2c8382aaec6c7ef2ae2482aeMichael Kolb } else { 75546f987eca738a36e2c8382aaec6c7ef2ae2482aeMichael Kolb return null; 75646f987eca738a36e2c8382aaec6c7ef2ae2482aeMichael Kolb } 757fdb7024334dffd63273eb9c424260b5fe633b94dMichael Kolb } 758fdb7024334dffd63273eb9c424260b5fe633b94dMichael Kolb 759fedb492d1ac1068e17028b6d4083d1a6b0578287Michael Kolb protected Menu getMenu() { 760fedb492d1ac1068e17028b6d4083d1a6b0578287Michael Kolb MenuBuilder menu = new MenuBuilder(mActivity); 761fedb492d1ac1068e17028b6d4083d1a6b0578287Michael Kolb mActivity.getMenuInflater().inflate(R.menu.browser, menu); 762fedb492d1ac1068e17028b6d4083d1a6b0578287Michael Kolb return menu; 763fedb492d1ac1068e17028b6d4083d1a6b0578287Michael Kolb } 764fedb492d1ac1068e17028b6d4083d1a6b0578287Michael Kolb 765c38c604eca3bd0620cd9284187aace78455e723dMichael Kolb public void setFullscreen(boolean enabled) { 766c5675ad4baf34547770a98c7c0d8dec7f8fb4999Michael Kolb Window win = mActivity.getWindow(); 767c5675ad4baf34547770a98c7c0d8dec7f8fb4999Michael Kolb WindowManager.LayoutParams winParams = win.getAttributes(); 76876dff39b75c73d2ab059a731866b84400704e196Michael Kolb final int bits = WindowManager.LayoutParams.FLAG_FULLSCREEN; 769c38c604eca3bd0620cd9284187aace78455e723dMichael Kolb if (enabled) { 770c5675ad4baf34547770a98c7c0d8dec7f8fb4999Michael Kolb winParams.flags |= bits; 771c38c604eca3bd0620cd9284187aace78455e723dMichael Kolb } else { 772c5675ad4baf34547770a98c7c0d8dec7f8fb4999Michael Kolb winParams.flags &= ~bits; 773c5675ad4baf34547770a98c7c0d8dec7f8fb4999Michael Kolb if (mCustomView != null) { 774c5675ad4baf34547770a98c7c0d8dec7f8fb4999Michael Kolb mCustomView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_VISIBLE); 775c5675ad4baf34547770a98c7c0d8dec7f8fb4999Michael Kolb } else { 776c5675ad4baf34547770a98c7c0d8dec7f8fb4999Michael Kolb mContentView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_VISIBLE); 777c5675ad4baf34547770a98c7c0d8dec7f8fb4999Michael Kolb } 778c38c604eca3bd0620cd9284187aace78455e723dMichael Kolb } 779c5675ad4baf34547770a98c7c0d8dec7f8fb4999Michael Kolb win.setAttributes(winParams); 780c38c604eca3bd0620cd9284187aace78455e723dMichael Kolb } 781c38c604eca3bd0620cd9284187aace78455e723dMichael Kolb 7820f602f3933dcd88702fdb514b6611e3066ca7a2bJohn Reck public Drawable getFaviconDrawable(Bitmap icon) { 7835a4372f4638f9a1fc5c052d85977fbcc0c4d8c55Michael Kolb Drawable[] array = new Drawable[3]; 7845a4372f4638f9a1fc5c052d85977fbcc0c4d8c55Michael Kolb array[0] = new PaintDrawable(Color.BLACK); 7855a4372f4638f9a1fc5c052d85977fbcc0c4d8c55Michael Kolb PaintDrawable p = new PaintDrawable(Color.WHITE); 7865a4372f4638f9a1fc5c052d85977fbcc0c4d8c55Michael Kolb array[1] = p; 7875a4372f4638f9a1fc5c052d85977fbcc0c4d8c55Michael Kolb if (icon == null) { 7885a4372f4638f9a1fc5c052d85977fbcc0c4d8c55Michael Kolb array[2] = mGenericFavicon; 7895a4372f4638f9a1fc5c052d85977fbcc0c4d8c55Michael Kolb } else { 7905a4372f4638f9a1fc5c052d85977fbcc0c4d8c55Michael Kolb array[2] = new BitmapDrawable(icon); 7915a4372f4638f9a1fc5c052d85977fbcc0c4d8c55Michael Kolb } 7925a4372f4638f9a1fc5c052d85977fbcc0c4d8c55Michael Kolb LayerDrawable d = new LayerDrawable(array); 7935a4372f4638f9a1fc5c052d85977fbcc0c4d8c55Michael Kolb d.setLayerInset(1, 1, 1, 1, 1); 7945a4372f4638f9a1fc5c052d85977fbcc0c4d8c55Michael Kolb d.setLayerInset(2, 2, 2, 2, 2); 7955a4372f4638f9a1fc5c052d85977fbcc0c4d8c55Michael Kolb return d; 7965a4372f4638f9a1fc5c052d85977fbcc0c4d8c55Michael Kolb } 7975a4372f4638f9a1fc5c052d85977fbcc0c4d8c55Michael Kolb 7985d43ce897758b7cb5deadc1203717b965334784cJohn Reck public boolean isLoading() { 7995d43ce897758b7cb5deadc1203717b965334784cJohn Reck return mActiveTab != null ? mActiveTab.inPageLoad() : false; 8005d43ce897758b7cb5deadc1203717b965334784cJohn Reck } 8015d43ce897758b7cb5deadc1203717b965334784cJohn Reck 8025d43ce897758b7cb5deadc1203717b965334784cJohn Reck /** 8035d43ce897758b7cb5deadc1203717b965334784cJohn Reck * Suggest to the UI that the title bar can be hidden. The UI will then 8045d43ce897758b7cb5deadc1203717b965334784cJohn Reck * decide whether or not to hide based off a number of factors, such 8055d43ce897758b7cb5deadc1203717b965334784cJohn Reck * as if the user is editing the URL bar or if the page is loading 8065d43ce897758b7cb5deadc1203717b965334784cJohn Reck */ 8075d43ce897758b7cb5deadc1203717b965334784cJohn Reck public void suggestHideTitleBar() { 80858891907e3cf77b72f1107ef5d9f4c984cb176edJohn Reck if (!isLoading() && !isEditingUrl() && !mTitleBar.wantsToBeVisible() 80958891907e3cf77b72f1107ef5d9f4c984cb176edJohn Reck && !mNavigationBar.isMenuShowing()) { 8105d43ce897758b7cb5deadc1203717b965334784cJohn Reck hideTitleBar(); 8115d43ce897758b7cb5deadc1203717b965334784cJohn Reck } 8125d43ce897758b7cb5deadc1203717b965334784cJohn Reck } 8135d43ce897758b7cb5deadc1203717b965334784cJohn Reck 814bc6adb4501853dbaba1c3bb592a159ee901b70e7John Reck protected final void showTitleBarForDuration() { 815bc6adb4501853dbaba1c3bb592a159ee901b70e7John Reck showTitleBarForDuration(HIDE_TITLEBAR_DELAY); 816bc6adb4501853dbaba1c3bb592a159ee901b70e7John Reck } 817bc6adb4501853dbaba1c3bb592a159ee901b70e7John Reck 818bc6adb4501853dbaba1c3bb592a159ee901b70e7John Reck protected final void showTitleBarForDuration(long duration) { 8196ac5bfda1a372219e469d965e94899d3b4895e0fJohn Reck showTitleBar(); 8206ac5bfda1a372219e469d965e94899d3b4895e0fJohn Reck Message msg = Message.obtain(mHandler, MSG_HIDE_TITLEBAR); 821bc6adb4501853dbaba1c3bb592a159ee901b70e7John Reck mHandler.sendMessageDelayed(msg, duration); 8226ac5bfda1a372219e469d965e94899d3b4895e0fJohn Reck } 8236ac5bfda1a372219e469d965e94899d3b4895e0fJohn Reck 8249c5004e6d5645cdf32fff3a3f04817a307b84dd6John Reck protected Handler mHandler = new Handler() { 8255d43ce897758b7cb5deadc1203717b965334784cJohn Reck 8265d43ce897758b7cb5deadc1203717b965334784cJohn Reck @Override 8275d43ce897758b7cb5deadc1203717b965334784cJohn Reck public void handleMessage(Message msg) { 8285d43ce897758b7cb5deadc1203717b965334784cJohn Reck if (msg.what == MSG_HIDE_TITLEBAR) { 8295d43ce897758b7cb5deadc1203717b965334784cJohn Reck suggestHideTitleBar(); 8305d43ce897758b7cb5deadc1203717b965334784cJohn Reck } 8319c5004e6d5645cdf32fff3a3f04817a307b84dd6John Reck BaseUi.this.handleMessage(msg); 8325d43ce897758b7cb5deadc1203717b965334784cJohn Reck } 8335d43ce897758b7cb5deadc1203717b965334784cJohn Reck }; 8343ba455394dd3413b6246f00d2bf2083547862735John Reck 8359c5004e6d5645cdf32fff3a3f04817a307b84dd6John Reck protected void handleMessage(Message msg) {} 8369c5004e6d5645cdf32fff3a3f04817a307b84dd6John Reck 8373ba455394dd3413b6246f00d2bf2083547862735John Reck @Override 8383ba455394dd3413b6246f00d2bf2083547862735John Reck public void showWeb(boolean animate) { 8393ba455394dd3413b6246f00d2bf2083547862735John Reck mUiController.hideCustomView(); 8403ba455394dd3413b6246f00d2bf2083547862735John Reck } 8413ba455394dd3413b6246f00d2bf2083547862735John Reck 84231065b1940cb70ad131f20e29ad6250f7d09a290Michael Kolb static class FullscreenHolder extends FrameLayout { 84353ed62c0171fdbaecaccfbbb08cbf22cb08d39a5Michael Kolb 84431065b1940cb70ad131f20e29ad6250f7d09a290Michael Kolb public FullscreenHolder(Context ctx) { 84531065b1940cb70ad131f20e29ad6250f7d09a290Michael Kolb super(ctx); 84631065b1940cb70ad131f20e29ad6250f7d09a290Michael Kolb setBackgroundColor(ctx.getResources().getColor(R.color.black)); 84753ed62c0171fdbaecaccfbbb08cbf22cb08d39a5Michael Kolb } 84853ed62c0171fdbaecaccfbbb08cbf22cb08d39a5Michael Kolb 84931065b1940cb70ad131f20e29ad6250f7d09a290Michael Kolb @Override 85031065b1940cb70ad131f20e29ad6250f7d09a290Michael Kolb public boolean onTouchEvent(MotionEvent evt) { 85131065b1940cb70ad131f20e29ad6250f7d09a290Michael Kolb return true; 85253ed62c0171fdbaecaccfbbb08cbf22cb08d39a5Michael Kolb } 85353ed62c0171fdbaecaccfbbb08cbf22cb08d39a5Michael Kolb 85431065b1940cb70ad131f20e29ad6250f7d09a290Michael Kolb } 8558233facddcc51865d612a919d450db6954aa48e3Michael Kolb} 856