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; 942711fab2fa2eb798e3aea90368f7ac5af1fbe523John Reck private FrameLayout mFixedTitlebarContainer; 958233facddcc51865d612a919d450db6954aa48e3Michael Kolb 9631065b1940cb70ad131f20e29ad6250f7d09a290Michael Kolb private View mCustomView; 978233facddcc51865d612a919d450db6954aa48e3Michael Kolb private WebChromeClient.CustomViewCallback mCustomViewCallback; 982d4f1e2553dee6bce5a12162ff6d4459babe2512Derek Sollenberger private int mOriginalOrientation; 998233facddcc51865d612a919d450db6954aa48e3Michael Kolb 1008233facddcc51865d612a919d450db6954aa48e3Michael Kolb private LinearLayout mErrorConsoleContainer = null; 1018233facddcc51865d612a919d450db6954aa48e3Michael Kolb 102718a24d6c9671fe2da4112a3b5f30fd3939b38e8John Reck private UrlBarAutoShowManager mUrlBarAutoShowManager; 1038233facddcc51865d612a919d450db6954aa48e3Michael Kolb 104718a24d6c9671fe2da4112a3b5f30fd3939b38e8John Reck private Toast mStopToast; 1055a4372f4638f9a1fc5c052d85977fbcc0c4d8c55Michael Kolb 1068233facddcc51865d612a919d450db6954aa48e3Michael Kolb // the default <video> poster 1078233facddcc51865d612a919d450db6954aa48e3Michael Kolb private Bitmap mDefaultVideoPoster; 1088233facddcc51865d612a919d450db6954aa48e3Michael Kolb // the video progress view 1098233facddcc51865d612a919d450db6954aa48e3Michael Kolb private View mVideoProgressView; 1108233facddcc51865d612a919d450db6954aa48e3Michael Kolb 1118233facddcc51865d612a919d450db6954aa48e3Michael Kolb private boolean mActivityPaused; 112bf2ec206e8743467961da3e857b07aad6c50cd67John Reck protected boolean mUseQuickControls; 1130f602f3933dcd88702fdb514b6611e3066ca7a2bJohn Reck protected TitleBar mTitleBar; 1140f602f3933dcd88702fdb514b6611e3066ca7a2bJohn Reck private NavigationBarBase mNavigationBar; 115da580634265a0add98d3c16b07103edbe724a5b3Michael Kolb protected PieControl mPieControl; 116bae0cb200f6ad93ce61c5781100f4b6ac0cb6649Michael Kolb private boolean mBlockFocusAnimations; 1178233facddcc51865d612a919d450db6954aa48e3Michael Kolb 1188233facddcc51865d612a919d450db6954aa48e3Michael Kolb public BaseUi(Activity browser, UiController controller) { 1198233facddcc51865d612a919d450db6954aa48e3Michael Kolb mActivity = browser; 1208233facddcc51865d612a919d450db6954aa48e3Michael Kolb mUiController = controller; 1218233facddcc51865d612a919d450db6954aa48e3Michael Kolb mTabControl = controller.getTabControl(); 1228233facddcc51865d612a919d450db6954aa48e3Michael Kolb Resources res = mActivity.getResources(); 1233a696280cba53eea153c9d5707b236997d193328Michael Kolb mInputManager = (InputMethodManager) 1243a696280cba53eea153c9d5707b236997d193328Michael Kolb browser.getSystemService(Activity.INPUT_METHOD_SERVICE); 1252466effd6ef97aa17396c214d51f9f19a4760260Steve Block mLockIconSecure = res.getDrawable(R.drawable.ic_secure_holo_dark); 1262466effd6ef97aa17396c214d51f9f19a4760260Steve Block mLockIconMixed = res.getDrawable(R.drawable.ic_secure_partial_holo_dark); 1278233facddcc51865d612a919d450db6954aa48e3Michael Kolb FrameLayout frameLayout = (FrameLayout) mActivity.getWindow() 1288233facddcc51865d612a919d450db6954aa48e3Michael Kolb .getDecorView().findViewById(android.R.id.content); 1297c6e1c928ea078034e7eacf32ef5c209138001d9John Reck LayoutInflater.from(mActivity) 1307c6e1c928ea078034e7eacf32ef5c209138001d9John Reck .inflate(R.layout.custom_screen, frameLayout); 1312711fab2fa2eb798e3aea90368f7ac5af1fbe523John Reck mFixedTitlebarContainer = (FrameLayout) frameLayout.findViewById( 1322711fab2fa2eb798e3aea90368f7ac5af1fbe523John Reck R.id.fixed_titlebar_container); 1337c6e1c928ea078034e7eacf32ef5c209138001d9John Reck mContentView = (FrameLayout) frameLayout.findViewById( 1348233facddcc51865d612a919d450db6954aa48e3Michael Kolb R.id.main_content); 13553ed62c0171fdbaecaccfbbb08cbf22cb08d39a5Michael Kolb mCustomViewContainer = (FrameLayout) frameLayout.findViewById( 13653ed62c0171fdbaecaccfbbb08cbf22cb08d39a5Michael Kolb R.id.fullscreen_custom_content); 1377c6e1c928ea078034e7eacf32ef5c209138001d9John Reck mErrorConsoleContainer = (LinearLayout) frameLayout 1388233facddcc51865d612a919d450db6954aa48e3Michael Kolb .findViewById(R.id.error_console); 139c38c604eca3bd0620cd9284187aace78455e723dMichael Kolb setFullscreen(BrowserSettings.getInstance().useFullscreen()); 1405a4372f4638f9a1fc5c052d85977fbcc0c4d8c55Michael Kolb mGenericFavicon = res.getDrawable( 1415a4372f4638f9a1fc5c052d85977fbcc0c4d8c55Michael Kolb R.drawable.app_web_browser_sm); 1420f602f3933dcd88702fdb514b6611e3066ca7a2bJohn Reck mTitleBar = new TitleBar(mActivity, mUiController, this, 1430f602f3933dcd88702fdb514b6611e3066ca7a2bJohn Reck mContentView); 1440f602f3933dcd88702fdb514b6611e3066ca7a2bJohn Reck mTitleBar.setProgress(100); 1450f602f3933dcd88702fdb514b6611e3066ca7a2bJohn Reck mNavigationBar = mTitleBar.getNavigationBar(); 146718a24d6c9671fe2da4112a3b5f30fd3939b38e8John Reck mUrlBarAutoShowManager = new UrlBarAutoShowManager(this); 1478233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 1488233facddcc51865d612a919d450db6954aa48e3Michael Kolb 1498233facddcc51865d612a919d450db6954aa48e3Michael Kolb private void cancelStopToast() { 1508233facddcc51865d612a919d450db6954aa48e3Michael Kolb if (mStopToast != null) { 1518233facddcc51865d612a919d450db6954aa48e3Michael Kolb mStopToast.cancel(); 1528233facddcc51865d612a919d450db6954aa48e3Michael Kolb mStopToast = null; 1538233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 1548233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 1558233facddcc51865d612a919d450db6954aa48e3Michael Kolb 1568233facddcc51865d612a919d450db6954aa48e3Michael Kolb // lifecycle 1578233facddcc51865d612a919d450db6954aa48e3Michael Kolb 1588233facddcc51865d612a919d450db6954aa48e3Michael Kolb public void onPause() { 1597a5cf4714453bd982afc662f373d0c38cddfb023Michael Kolb if (isCustomViewShowing()) { 1607a5cf4714453bd982afc662f373d0c38cddfb023Michael Kolb onHideCustomView(); 1617a5cf4714453bd982afc662f373d0c38cddfb023Michael Kolb } 1628233facddcc51865d612a919d450db6954aa48e3Michael Kolb cancelStopToast(); 1638233facddcc51865d612a919d450db6954aa48e3Michael Kolb mActivityPaused = true; 1648233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 1658233facddcc51865d612a919d450db6954aa48e3Michael Kolb 1668233facddcc51865d612a919d450db6954aa48e3Michael Kolb public void onResume() { 1678233facddcc51865d612a919d450db6954aa48e3Michael Kolb mActivityPaused = false; 1682ae6ef7f6c146a5bc3a4c7ef8de56505eb02399eMichael Kolb // check if we exited without setting active tab 1692ae6ef7f6c146a5bc3a4c7ef8de56505eb02399eMichael Kolb // b: 5188145 1701a4625a4fa1f3aae01de5cee5338ee4552edd3e8Michael Kolb final Tab ct = mTabControl.getCurrentTab(); 1711a4625a4fa1f3aae01de5cee5338ee4552edd3e8Michael Kolb if (ct != null) { 1721a4625a4fa1f3aae01de5cee5338ee4552edd3e8Michael Kolb setActiveTab(ct); 1731a4625a4fa1f3aae01de5cee5338ee4552edd3e8Michael Kolb } 1741cc1d1d08c50211e4f9f8407978d0435a0110375John Reck mTitleBar.onResume(); 1758233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 1768233facddcc51865d612a919d450db6954aa48e3Michael Kolb 1776670653d355fea0ae20dc51f6c693f994c4cbb54Michael Kolb protected boolean isActivityPaused() { 1786670653d355fea0ae20dc51f6c693f994c4cbb54Michael Kolb return mActivityPaused; 1798233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 1808233facddcc51865d612a919d450db6954aa48e3Michael Kolb 1818233facddcc51865d612a919d450db6954aa48e3Michael Kolb public void onConfigurationChanged(Configuration config) { 1828233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 1838233facddcc51865d612a919d450db6954aa48e3Michael Kolb 1840f602f3933dcd88702fdb514b6611e3066ca7a2bJohn Reck public Activity getActivity() { 1850f602f3933dcd88702fdb514b6611e3066ca7a2bJohn Reck return mActivity; 1860f602f3933dcd88702fdb514b6611e3066ca7a2bJohn Reck } 1870f602f3933dcd88702fdb514b6611e3066ca7a2bJohn Reck 1888233facddcc51865d612a919d450db6954aa48e3Michael Kolb // key handling 1898233facddcc51865d612a919d450db6954aa48e3Michael Kolb 1908233facddcc51865d612a919d450db6954aa48e3Michael Kolb @Override 1918233facddcc51865d612a919d450db6954aa48e3Michael Kolb public boolean onBackKey() { 1928233facddcc51865d612a919d450db6954aa48e3Michael Kolb if (mCustomView != null) { 1938233facddcc51865d612a919d450db6954aa48e3Michael Kolb mUiController.hideCustomView(); 1948233facddcc51865d612a919d450db6954aa48e3Michael Kolb return true; 1958233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 1968233facddcc51865d612a919d450db6954aa48e3Michael Kolb return false; 1978233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 1988233facddcc51865d612a919d450db6954aa48e3Michael Kolb 1992814a362c21ac219410d9b54e1bd3e8152b845c7Michael Kolb @Override 2002814a362c21ac219410d9b54e1bd3e8152b845c7Michael Kolb public boolean onMenuKey() { 2012814a362c21ac219410d9b54e1bd3e8152b845c7Michael Kolb return false; 2022814a362c21ac219410d9b54e1bd3e8152b845c7Michael Kolb } 2032814a362c21ac219410d9b54e1bd3e8152b845c7Michael Kolb 204da580634265a0add98d3c16b07103edbe724a5b3Michael Kolb @Override 205da580634265a0add98d3c16b07103edbe724a5b3Michael Kolb public void setUseQuickControls(boolean useQuickControls) { 206da580634265a0add98d3c16b07103edbe724a5b3Michael Kolb mUseQuickControls = useQuickControls; 207da580634265a0add98d3c16b07103edbe724a5b3Michael Kolb mTitleBar.setUseQuickControls(mUseQuickControls); 208da580634265a0add98d3c16b07103edbe724a5b3Michael Kolb if (useQuickControls) { 209da580634265a0add98d3c16b07103edbe724a5b3Michael Kolb mPieControl = new PieControl(mActivity, mUiController, this); 210da580634265a0add98d3c16b07103edbe724a5b3Michael Kolb mPieControl.attachToContainer(mContentView); 211da580634265a0add98d3c16b07103edbe724a5b3Michael Kolb } else { 212da580634265a0add98d3c16b07103edbe724a5b3Michael Kolb if (mPieControl != null) { 213da580634265a0add98d3c16b07103edbe724a5b3Michael Kolb mPieControl.removeFromContainer(mContentView); 214da580634265a0add98d3c16b07103edbe724a5b3Michael Kolb } 215da580634265a0add98d3c16b07103edbe724a5b3Michael Kolb } 216da580634265a0add98d3c16b07103edbe724a5b3Michael Kolb updateUrlBarAutoShowManagerTarget(); 217da580634265a0add98d3c16b07103edbe724a5b3Michael Kolb } 218da580634265a0add98d3c16b07103edbe724a5b3Michael Kolb 21930c714c853a4239e72ab1e238ce2a92472d06ab0John Reck // Tab callbacks 2208233facddcc51865d612a919d450db6954aa48e3Michael Kolb @Override 22130c714c853a4239e72ab1e238ce2a92472d06ab0John Reck public void onTabDataChanged(Tab tab) { 22230c714c853a4239e72ab1e238ce2a92472d06ab0John Reck setUrlTitle(tab); 22330c714c853a4239e72ab1e238ce2a92472d06ab0John Reck setFavicon(tab); 22430c714c853a4239e72ab1e238ce2a92472d06ab0John Reck updateLockIconToLatest(tab); 2255a72f1858c2f73be3558c6cdaa2c84b4c36fa748Michael Kolb updateNavigationState(tab); 226ef654f1dd80f55609060005342fc4f2cde62990cJohn Reck mTitleBar.onTabDataChanged(tab); 227419f6b4136a8fac758e2159f223700b1dfcc20e2John Reck mNavigationBar.onTabDataChanged(tab); 228a53c98902be0f9f959b6af06227254e5ad2130c9Michael Kolb onProgressChanged(tab); 2298233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 2308233facddcc51865d612a919d450db6954aa48e3Michael Kolb 2318233facddcc51865d612a919d450db6954aa48e3Michael Kolb @Override 232e8a823329e004c4261ee5f810e1ca3ebd90914ddMichael Kolb public void onProgressChanged(Tab tab) { 233e8a823329e004c4261ee5f810e1ca3ebd90914ddMichael Kolb int progress = tab.getLoadProgress(); 234e8a823329e004c4261ee5f810e1ca3ebd90914ddMichael Kolb if (tab.inForeground()) { 235e8a823329e004c4261ee5f810e1ca3ebd90914ddMichael Kolb mTitleBar.setProgress(progress); 236e8a823329e004c4261ee5f810e1ca3ebd90914ddMichael Kolb } 237e8a823329e004c4261ee5f810e1ca3ebd90914ddMichael Kolb } 238e8a823329e004c4261ee5f810e1ca3ebd90914ddMichael Kolb 239e8a823329e004c4261ee5f810e1ca3ebd90914ddMichael Kolb @Override 2404cd97793901e8f5681cf642d0b2684697964a37aLeon Scroggins public void bookmarkedStatusHasChanged(Tab tab) { 24194b7e04932d77d73f348efecf7f2dd6b4ee5e5a1John Reck if (tab.inForeground()) { 24294b7e04932d77d73f348efecf7f2dd6b4ee5e5a1John Reck boolean isBookmark = tab.isBookmarkedSite(); 2430f602f3933dcd88702fdb514b6611e3066ca7a2bJohn Reck mNavigationBar.setCurrentUrlIsBookmark(isBookmark); 24494b7e04932d77d73f348efecf7f2dd6b4ee5e5a1John Reck } 2454cd97793901e8f5681cf642d0b2684697964a37aLeon Scroggins } 2464cd97793901e8f5681cf642d0b2684697964a37aLeon Scroggins 2474cd97793901e8f5681cf642d0b2684697964a37aLeon Scroggins @Override 2488233facddcc51865d612a919d450db6954aa48e3Michael Kolb public void onPageStopped(Tab tab) { 2498233facddcc51865d612a919d450db6954aa48e3Michael Kolb cancelStopToast(); 2508233facddcc51865d612a919d450db6954aa48e3Michael Kolb if (tab.inForeground()) { 2518233facddcc51865d612a919d450db6954aa48e3Michael Kolb mStopToast = Toast 2528233facddcc51865d612a919d450db6954aa48e3Michael Kolb .makeText(mActivity, R.string.stopping, Toast.LENGTH_SHORT); 2538233facddcc51865d612a919d450db6954aa48e3Michael Kolb mStopToast.show(); 2548233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 2558233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 2568233facddcc51865d612a919d450db6954aa48e3Michael Kolb 2578233facddcc51865d612a919d450db6954aa48e3Michael Kolb @Override 2581bf231334fd4bda8dbde5b9a0345c756a213b3a2Michael Kolb public boolean needsRestoreAllTabs() { 259847b532045e3cb117a847ebb956c9919401f332dJohn Reck return true; 2601bf231334fd4bda8dbde5b9a0345c756a213b3a2Michael Kolb } 2611bf231334fd4bda8dbde5b9a0345c756a213b3a2Michael Kolb 2621bf231334fd4bda8dbde5b9a0345c756a213b3a2Michael Kolb @Override 2638233facddcc51865d612a919d450db6954aa48e3Michael Kolb public void addTab(Tab tab) { 2648233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 2658233facddcc51865d612a919d450db6954aa48e3Michael Kolb 2668233facddcc51865d612a919d450db6954aa48e3Michael Kolb @Override 267377ea31324391e7878f6f5b7a991c74988c18403Michael Kolb public void setActiveTab(final Tab tab) { 2687ac63b64e9f127057f93b12fb65400c5a6dee7c4Michael Kolb if (tab == null) return; 269bae0cb200f6ad93ce61c5781100f4b6ac0cb6649Michael Kolb // block unnecessary focus change animations during tab switch 270bae0cb200f6ad93ce61c5781100f4b6ac0cb6649Michael Kolb mBlockFocusAnimations = true; 2715d43ce897758b7cb5deadc1203717b965334784cJohn Reck mHandler.removeMessages(MSG_HIDE_TITLEBAR); 27277df4568331d527f993f4d69168218ddf5acdddaMichael Kolb if ((tab != mActiveTab) && (mActiveTab != null)) { 27377df4568331d527f993f4d69168218ddf5acdddaMichael Kolb removeTabFromContentView(mActiveTab); 274bf2ec206e8743467961da3e857b07aad6c50cd67John Reck WebView web = mActiveTab.getWebView(); 275bf2ec206e8743467961da3e857b07aad6c50cd67John Reck if (web != null) { 276bf2ec206e8743467961da3e857b07aad6c50cd67John Reck web.setOnTouchListener(null); 277bf2ec206e8743467961da3e857b07aad6c50cd67John Reck } 2788233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 27977df4568331d527f993f4d69168218ddf5acdddaMichael Kolb mActiveTab = tab; 280da580634265a0add98d3c16b07103edbe724a5b3Michael Kolb BrowserWebView web = (BrowserWebView) mActiveTab.getWebView(); 281718a24d6c9671fe2da4112a3b5f30fd3939b38e8John Reck updateUrlBarAutoShowManagerTarget(); 2825d43ce897758b7cb5deadc1203717b965334784cJohn Reck attachTabToContentView(tab); 283da580634265a0add98d3c16b07103edbe724a5b3Michael Kolb if (web != null) { 284da580634265a0add98d3c16b07103edbe724a5b3Michael Kolb // Request focus on the top window. 285da580634265a0add98d3c16b07103edbe724a5b3Michael Kolb if (mUseQuickControls) { 286da580634265a0add98d3c16b07103edbe724a5b3Michael Kolb mPieControl.forceToTop(mContentView); 287da580634265a0add98d3c16b07103edbe724a5b3Michael Kolb web.setTitleBar(null); 288e8a823329e004c4261ee5f810e1ca3ebd90914ddMichael Kolb mTitleBar.hide(); 289da580634265a0add98d3c16b07103edbe724a5b3Michael Kolb } else { 290da580634265a0add98d3c16b07103edbe724a5b3Michael Kolb web.setTitleBar(mTitleBar); 291da580634265a0add98d3c16b07103edbe724a5b3Michael Kolb mTitleBar.onScrollChanged(); 292da580634265a0add98d3c16b07103edbe724a5b3Michael Kolb } 293da580634265a0add98d3c16b07103edbe724a5b3Michael Kolb } 2944923c22cb79296a9624a599cf8874323cdbc6cbcMichael Kolb mTitleBar.bringToFront(); 295f8963521024f39236388eb8e70835f813bf7f4eeMichael Kolb tab.getTopWindow().requestFocus(); 2968233facddcc51865d612a919d450db6954aa48e3Michael Kolb setShouldShowErrorConsole(tab, mUiController.shouldShowErrorConsole()); 29730c714c853a4239e72ab1e238ce2a92472d06ab0John Reck onTabDataChanged(tab); 29830c714c853a4239e72ab1e238ce2a92472d06ab0John Reck onProgressChanged(tab); 29903b6bc6dc3644e9843f2ff05bca543e546fe3a61Michael Kolb mNavigationBar.setIncognitoMode(tab.isPrivateBrowsingEnabled()); 3009206677e461328f15854c5fcb1366d0e261534c6Patrick Scott updateAutoLogin(tab, false); 301bae0cb200f6ad93ce61c5781100f4b6ac0cb6649Michael Kolb mBlockFocusAnimations = false; 3028233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 3038233facddcc51865d612a919d450db6954aa48e3Michael Kolb 304718a24d6c9671fe2da4112a3b5f30fd3939b38e8John Reck protected void updateUrlBarAutoShowManagerTarget() { 305718a24d6c9671fe2da4112a3b5f30fd3939b38e8John Reck WebView web = mActiveTab != null ? mActiveTab.getWebView() : null; 306718a24d6c9671fe2da4112a3b5f30fd3939b38e8John Reck if (!mUseQuickControls && web instanceof BrowserWebView) { 307718a24d6c9671fe2da4112a3b5f30fd3939b38e8John Reck mUrlBarAutoShowManager.setTarget((BrowserWebView) web); 308718a24d6c9671fe2da4112a3b5f30fd3939b38e8John Reck } else { 309718a24d6c9671fe2da4112a3b5f30fd3939b38e8John Reck mUrlBarAutoShowManager.setTarget(null); 310718a24d6c9671fe2da4112a3b5f30fd3939b38e8John Reck } 311718a24d6c9671fe2da4112a3b5f30fd3939b38e8John Reck } 312718a24d6c9671fe2da4112a3b5f30fd3939b38e8John Reck 313cfa3af5c59abb38c895416a80ef16da0ec1b5287Michael Kolb Tab getActiveTab() { 314cfa3af5c59abb38c895416a80ef16da0ec1b5287Michael Kolb return mActiveTab; 315cfa3af5c59abb38c895416a80ef16da0ec1b5287Michael Kolb } 316cfa3af5c59abb38c895416a80ef16da0ec1b5287Michael Kolb 3178233facddcc51865d612a919d450db6954aa48e3Michael Kolb @Override 3181bf231334fd4bda8dbde5b9a0345c756a213b3a2Michael Kolb public void updateTabs(List<Tab> tabs) { 3191bf231334fd4bda8dbde5b9a0345c756a213b3a2Michael Kolb } 3201bf231334fd4bda8dbde5b9a0345c756a213b3a2Michael Kolb 3211bf231334fd4bda8dbde5b9a0345c756a213b3a2Michael Kolb @Override 3228233facddcc51865d612a919d450db6954aa48e3Michael Kolb public void removeTab(Tab tab) { 32377df4568331d527f993f4d69168218ddf5acdddaMichael Kolb if (mActiveTab == tab) { 3248233facddcc51865d612a919d450db6954aa48e3Michael Kolb removeTabFromContentView(tab); 32577df4568331d527f993f4d69168218ddf5acdddaMichael Kolb mActiveTab = null; 3268233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 3278233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 3288233facddcc51865d612a919d450db6954aa48e3Michael Kolb 3298233facddcc51865d612a919d450db6954aa48e3Michael Kolb @Override 3308233facddcc51865d612a919d450db6954aa48e3Michael Kolb public void detachTab(Tab tab) { 3318233facddcc51865d612a919d450db6954aa48e3Michael Kolb removeTabFromContentView(tab); 3328233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 3338233facddcc51865d612a919d450db6954aa48e3Michael Kolb 3348233facddcc51865d612a919d450db6954aa48e3Michael Kolb @Override 3358233facddcc51865d612a919d450db6954aa48e3Michael Kolb public void attachTab(Tab tab) { 3368233facddcc51865d612a919d450db6954aa48e3Michael Kolb attachTabToContentView(tab); 3378233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 3388233facddcc51865d612a919d450db6954aa48e3Michael Kolb 339377ea31324391e7878f6f5b7a991c74988c18403Michael Kolb protected void attachTabToContentView(Tab tab) { 340d1e2ccc38a2d5318a4ab06b2349cb43303fd6cebMichael Kolb if ((tab == null) || (tab.getWebView() == null)) { 3418233facddcc51865d612a919d450db6954aa48e3Michael Kolb return; 3428233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 3438233facddcc51865d612a919d450db6954aa48e3Michael Kolb View container = tab.getViewContainer(); 3448233facddcc51865d612a919d450db6954aa48e3Michael Kolb WebView mainView = tab.getWebView(); 3458233facddcc51865d612a919d450db6954aa48e3Michael Kolb // Attach the WebView to the container and then attach the 3468233facddcc51865d612a919d450db6954aa48e3Michael Kolb // container to the content view. 3478233facddcc51865d612a919d450db6954aa48e3Michael Kolb FrameLayout wrapper = 3488233facddcc51865d612a919d450db6954aa48e3Michael Kolb (FrameLayout) container.findViewById(R.id.webview_wrapper); 3498233facddcc51865d612a919d450db6954aa48e3Michael Kolb ViewGroup parent = (ViewGroup) mainView.getParent(); 3508233facddcc51865d612a919d450db6954aa48e3Michael Kolb if (parent != wrapper) { 3518233facddcc51865d612a919d450db6954aa48e3Michael Kolb if (parent != null) { 3528233facddcc51865d612a919d450db6954aa48e3Michael Kolb parent.removeView(mainView); 3538233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 3548233facddcc51865d612a919d450db6954aa48e3Michael Kolb wrapper.addView(mainView); 3558233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 3568233facddcc51865d612a919d450db6954aa48e3Michael Kolb parent = (ViewGroup) container.getParent(); 3578233facddcc51865d612a919d450db6954aa48e3Michael Kolb if (parent != mContentView) { 3588233facddcc51865d612a919d450db6954aa48e3Michael Kolb if (parent != null) { 3598233facddcc51865d612a919d450db6954aa48e3Michael Kolb parent.removeView(container); 3608233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 3618233facddcc51865d612a919d450db6954aa48e3Michael Kolb mContentView.addView(container, COVER_SCREEN_PARAMS); 3628233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 3638233facddcc51865d612a919d450db6954aa48e3Michael Kolb mUiController.attachSubWindow(tab); 3648233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 3658233facddcc51865d612a919d450db6954aa48e3Michael Kolb 3668233facddcc51865d612a919d450db6954aa48e3Michael Kolb private void removeTabFromContentView(Tab tab) { 3677cdc4906fc5852297a9a254c3251ad2f4dead6eeMichael Kolb hideTitleBar(); 3688233facddcc51865d612a919d450db6954aa48e3Michael Kolb // Remove the container that contains the main WebView. 3698233facddcc51865d612a919d450db6954aa48e3Michael Kolb WebView mainView = tab.getWebView(); 3708233facddcc51865d612a919d450db6954aa48e3Michael Kolb View container = tab.getViewContainer(); 3718233facddcc51865d612a919d450db6954aa48e3Michael Kolb if (mainView == null) { 3728233facddcc51865d612a919d450db6954aa48e3Michael Kolb return; 3738233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 3748233facddcc51865d612a919d450db6954aa48e3Michael Kolb // Remove the container from the content and then remove the 3758233facddcc51865d612a919d450db6954aa48e3Michael Kolb // WebView from the container. This will trigger a focus change 3768233facddcc51865d612a919d450db6954aa48e3Michael Kolb // needed by WebView. 3778233facddcc51865d612a919d450db6954aa48e3Michael Kolb FrameLayout wrapper = 3788233facddcc51865d612a919d450db6954aa48e3Michael Kolb (FrameLayout) container.findViewById(R.id.webview_wrapper); 3798233facddcc51865d612a919d450db6954aa48e3Michael Kolb wrapper.removeView(mainView); 3808233facddcc51865d612a919d450db6954aa48e3Michael Kolb mContentView.removeView(container); 3818233facddcc51865d612a919d450db6954aa48e3Michael Kolb mUiController.endActionMode(); 3828233facddcc51865d612a919d450db6954aa48e3Michael Kolb mUiController.removeSubWindow(tab); 3838233facddcc51865d612a919d450db6954aa48e3Michael Kolb ErrorConsoleView errorConsole = tab.getErrorConsole(false); 3848233facddcc51865d612a919d450db6954aa48e3Michael Kolb if (errorConsole != null) { 3858233facddcc51865d612a919d450db6954aa48e3Michael Kolb mErrorConsoleContainer.removeView(errorConsole); 3868233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 3878233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 3888233facddcc51865d612a919d450db6954aa48e3Michael Kolb 389a713ec8cc9da6c0c8078cd297c6240eb8bf01bbbMichael Kolb @Override 390a713ec8cc9da6c0c8078cd297c6240eb8bf01bbbMichael Kolb public void onSetWebView(Tab tab, WebView webView) { 391a713ec8cc9da6c0c8078cd297c6240eb8bf01bbbMichael Kolb View container = tab.getViewContainer(); 392a713ec8cc9da6c0c8078cd297c6240eb8bf01bbbMichael Kolb if (container == null) { 393a713ec8cc9da6c0c8078cd297c6240eb8bf01bbbMichael Kolb // The tab consists of a container view, which contains the main 394a713ec8cc9da6c0c8078cd297c6240eb8bf01bbbMichael Kolb // WebView, as well as any other UI elements associated with the tab. 395a713ec8cc9da6c0c8078cd297c6240eb8bf01bbbMichael Kolb container = mActivity.getLayoutInflater().inflate(R.layout.tab, 3967c6e1c928ea078034e7eacf32ef5c209138001d9John Reck mContentView, false); 397a713ec8cc9da6c0c8078cd297c6240eb8bf01bbbMichael Kolb tab.setViewContainer(container); 398a713ec8cc9da6c0c8078cd297c6240eb8bf01bbbMichael Kolb } 399a713ec8cc9da6c0c8078cd297c6240eb8bf01bbbMichael Kolb if (tab.getWebView() != webView) { 400a713ec8cc9da6c0c8078cd297c6240eb8bf01bbbMichael Kolb // Just remove the old one. 401a713ec8cc9da6c0c8078cd297c6240eb8bf01bbbMichael Kolb FrameLayout wrapper = 402a713ec8cc9da6c0c8078cd297c6240eb8bf01bbbMichael Kolb (FrameLayout) container.findViewById(R.id.webview_wrapper); 403a713ec8cc9da6c0c8078cd297c6240eb8bf01bbbMichael Kolb wrapper.removeView(tab.getWebView()); 404a713ec8cc9da6c0c8078cd297c6240eb8bf01bbbMichael Kolb } 405a713ec8cc9da6c0c8078cd297c6240eb8bf01bbbMichael Kolb } 406a713ec8cc9da6c0c8078cd297c6240eb8bf01bbbMichael Kolb 4078233facddcc51865d612a919d450db6954aa48e3Michael Kolb /** 4081514bb7ed5656316a8dac966cee21653f3c59affMichael Kolb * create a sub window container and webview for the tab 4091514bb7ed5656316a8dac966cee21653f3c59affMichael Kolb * Note: this methods operates through side-effects for now 4101514bb7ed5656316a8dac966cee21653f3c59affMichael Kolb * it sets both the subView and subViewContainer for the given tab 4111514bb7ed5656316a8dac966cee21653f3c59affMichael Kolb * @param tab tab to create the sub window for 4121514bb7ed5656316a8dac966cee21653f3c59affMichael Kolb * @param subView webview to be set as a subwindow for the tab 4131514bb7ed5656316a8dac966cee21653f3c59affMichael Kolb */ 4141514bb7ed5656316a8dac966cee21653f3c59affMichael Kolb @Override 4151514bb7ed5656316a8dac966cee21653f3c59affMichael Kolb public void createSubWindow(Tab tab, WebView subView) { 4161514bb7ed5656316a8dac966cee21653f3c59affMichael Kolb View subViewContainer = mActivity.getLayoutInflater().inflate( 4171514bb7ed5656316a8dac966cee21653f3c59affMichael Kolb R.layout.browser_subwindow, null); 4181514bb7ed5656316a8dac966cee21653f3c59affMichael Kolb ViewGroup inner = (ViewGroup) subViewContainer 4191514bb7ed5656316a8dac966cee21653f3c59affMichael Kolb .findViewById(R.id.inner_container); 4201514bb7ed5656316a8dac966cee21653f3c59affMichael Kolb inner.addView(subView, new LayoutParams(LayoutParams.MATCH_PARENT, 4211514bb7ed5656316a8dac966cee21653f3c59affMichael Kolb LayoutParams.MATCH_PARENT)); 4221514bb7ed5656316a8dac966cee21653f3c59affMichael Kolb final ImageButton cancel = (ImageButton) subViewContainer 4231514bb7ed5656316a8dac966cee21653f3c59affMichael Kolb .findViewById(R.id.subwindow_close); 4241514bb7ed5656316a8dac966cee21653f3c59affMichael Kolb final WebView cancelSubView = subView; 4251514bb7ed5656316a8dac966cee21653f3c59affMichael Kolb cancel.setOnClickListener(new OnClickListener() { 4261514bb7ed5656316a8dac966cee21653f3c59affMichael Kolb public void onClick(View v) { 4274d2fcaba7fb8eb1723943ac9a10e76d509330bd1Jonathan Dixon WebViewClassic.fromWebView(cancelSubView).getWebChromeClient().onCloseWindow( 4284d2fcaba7fb8eb1723943ac9a10e76d509330bd1Jonathan Dixon cancelSubView); 4291514bb7ed5656316a8dac966cee21653f3c59affMichael Kolb } 4301514bb7ed5656316a8dac966cee21653f3c59affMichael Kolb }); 4311514bb7ed5656316a8dac966cee21653f3c59affMichael Kolb tab.setSubWebView(subView); 4321514bb7ed5656316a8dac966cee21653f3c59affMichael Kolb tab.setSubViewContainer(subViewContainer); 4331514bb7ed5656316a8dac966cee21653f3c59affMichael Kolb } 4341514bb7ed5656316a8dac966cee21653f3c59affMichael Kolb 4351514bb7ed5656316a8dac966cee21653f3c59affMichael Kolb /** 4368233facddcc51865d612a919d450db6954aa48e3Michael Kolb * Remove the sub window from the content view. 4378233facddcc51865d612a919d450db6954aa48e3Michael Kolb */ 4388233facddcc51865d612a919d450db6954aa48e3Michael Kolb @Override 4398233facddcc51865d612a919d450db6954aa48e3Michael Kolb public void removeSubWindow(View subviewContainer) { 4408233facddcc51865d612a919d450db6954aa48e3Michael Kolb mContentView.removeView(subviewContainer); 4418233facddcc51865d612a919d450db6954aa48e3Michael Kolb mUiController.endActionMode(); 4428233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 4438233facddcc51865d612a919d450db6954aa48e3Michael Kolb 4448233facddcc51865d612a919d450db6954aa48e3Michael Kolb /** 4458233facddcc51865d612a919d450db6954aa48e3Michael Kolb * Attach the sub window to the content view. 4468233facddcc51865d612a919d450db6954aa48e3Michael Kolb */ 4478233facddcc51865d612a919d450db6954aa48e3Michael Kolb @Override 4488233facddcc51865d612a919d450db6954aa48e3Michael Kolb public void attachSubWindow(View container) { 4491514bb7ed5656316a8dac966cee21653f3c59affMichael Kolb if (container.getParent() != null) { 4501514bb7ed5656316a8dac966cee21653f3c59affMichael Kolb // already attached, remove first 4511514bb7ed5656316a8dac966cee21653f3c59affMichael Kolb ((ViewGroup) container.getParent()).removeView(container); 4521514bb7ed5656316a8dac966cee21653f3c59affMichael Kolb } 4538233facddcc51865d612a919d450db6954aa48e3Michael Kolb mContentView.addView(container, COVER_SCREEN_PARAMS); 4548233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 4558233facddcc51865d612a919d450db6954aa48e3Michael Kolb 45611d1978d8d16004598347abc93918b54a5ef760bMichael Kolb protected void refreshWebView() { 45746f987eca738a36e2c8382aaec6c7ef2ae2482aeMichael Kolb WebView web = getWebView(); 45846f987eca738a36e2c8382aaec6c7ef2ae2482aeMichael Kolb if (web != null) { 45946f987eca738a36e2c8382aaec6c7ef2ae2482aeMichael Kolb web.invalidate(); 46046f987eca738a36e2c8382aaec6c7ef2ae2482aeMichael Kolb } 46146f987eca738a36e2c8382aaec6c7ef2ae2482aeMichael Kolb } 46246f987eca738a36e2c8382aaec6c7ef2ae2482aeMichael Kolb 4631f9b3565dbd1911dfe4d9bfd8b833a5ac5f2e0c4Michael Kolb public void editUrl(boolean clearInput, boolean forceIME) { 46446f987eca738a36e2c8382aaec6c7ef2ae2482aeMichael Kolb if (mUiController.isInCustomActionMode()) { 46546f987eca738a36e2c8382aaec6c7ef2ae2482aeMichael Kolb mUiController.endActionMode(); 46611d1978d8d16004598347abc93918b54a5ef760bMichael Kolb } 46746f987eca738a36e2c8382aaec6c7ef2ae2482aeMichael Kolb showTitleBar(); 468ace2ff88b860c60c634d6cd49177eb4c5413228bMichael Kolb if ((getActiveTab() != null) && !getActiveTab().isSnapshot()) { 4691f9b3565dbd1911dfe4d9bfd8b833a5ac5f2e0c4Michael Kolb mNavigationBar.startEditingUrl(clearInput, forceIME); 470ef654f1dd80f55609060005342fc4f2cde62990cJohn Reck } 47111d1978d8d16004598347abc93918b54a5ef760bMichael Kolb } 47211d1978d8d16004598347abc93918b54a5ef760bMichael Kolb 4737cdc4906fc5852297a9a254c3251ad2f4dead6eeMichael Kolb boolean canShowTitleBar() { 4747cdc4906fc5852297a9a254c3251ad2f4dead6eeMichael Kolb return !isTitleBarShowing() 4757cdc4906fc5852297a9a254c3251ad2f4dead6eeMichael Kolb && !isActivityPaused() 4767cdc4906fc5852297a9a254c3251ad2f4dead6eeMichael Kolb && (getActiveTab() != null) 47746f987eca738a36e2c8382aaec6c7ef2ae2482aeMichael Kolb && (getWebView() != null) 4787cdc4906fc5852297a9a254c3251ad2f4dead6eeMichael Kolb && !mUiController.isInCustomActionMode(); 4798233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 4808233facddcc51865d612a919d450db6954aa48e3Michael Kolb 4810f602f3933dcd88702fdb514b6611e3066ca7a2bJohn Reck protected void showTitleBar() { 482ef654f1dd80f55609060005342fc4f2cde62990cJohn Reck mHandler.removeMessages(MSG_HIDE_TITLEBAR); 48346f987eca738a36e2c8382aaec6c7ef2ae2482aeMichael Kolb if (canShowTitleBar()) { 4840f602f3933dcd88702fdb514b6611e3066ca7a2bJohn Reck mTitleBar.show(); 48546f987eca738a36e2c8382aaec6c7ef2ae2482aeMichael Kolb } 4867cdc4906fc5852297a9a254c3251ad2f4dead6eeMichael Kolb } 4876670653d355fea0ae20dc51f6c693f994c4cbb54Michael Kolb 4887cdc4906fc5852297a9a254c3251ad2f4dead6eeMichael Kolb protected void hideTitleBar() { 4890f602f3933dcd88702fdb514b6611e3066ca7a2bJohn Reck if (mTitleBar.isShowing()) { 4900f602f3933dcd88702fdb514b6611e3066ca7a2bJohn Reck mTitleBar.hide(); 49146f987eca738a36e2c8382aaec6c7ef2ae2482aeMichael Kolb } 4927cdc4906fc5852297a9a254c3251ad2f4dead6eeMichael Kolb } 4936670653d355fea0ae20dc51f6c693f994c4cbb54Michael Kolb 4947cdc4906fc5852297a9a254c3251ad2f4dead6eeMichael Kolb protected boolean isTitleBarShowing() { 4950f602f3933dcd88702fdb514b6611e3066ca7a2bJohn Reck return mTitleBar.isShowing(); 4967cdc4906fc5852297a9a254c3251ad2f4dead6eeMichael Kolb } 4976670653d355fea0ae20dc51f6c693f994c4cbb54Michael Kolb 4985d43ce897758b7cb5deadc1203717b965334784cJohn Reck public boolean isEditingUrl() { 4990f602f3933dcd88702fdb514b6611e3066ca7a2bJohn Reck return mTitleBar.isEditingUrl(); 5005d43ce897758b7cb5deadc1203717b965334784cJohn Reck } 5015d43ce897758b7cb5deadc1203717b965334784cJohn Reck 50280f750852edf43c6b09e5633f2c6ebdb2ed94a5bMichael Kolb public void stopEditingUrl() { 50380f750852edf43c6b09e5633f2c6ebdb2ed94a5bMichael Kolb mTitleBar.getNavigationBar().stopEditingUrl(); 50480f750852edf43c6b09e5633f2c6ebdb2ed94a5bMichael Kolb } 50580f750852edf43c6b09e5633f2c6ebdb2ed94a5bMichael Kolb 5060f602f3933dcd88702fdb514b6611e3066ca7a2bJohn Reck public TitleBar getTitleBar() { 5070f602f3933dcd88702fdb514b6611e3066ca7a2bJohn Reck return mTitleBar; 5080f602f3933dcd88702fdb514b6611e3066ca7a2bJohn Reck } 5096670653d355fea0ae20dc51f6c693f994c4cbb54Michael Kolb 5106670653d355fea0ae20dc51f6c693f994c4cbb54Michael Kolb @Override 5112bc8042224be51966d748b870768ec1b376a1621John Reck public void showComboView(ComboViews startingView, Bundle extras) { 512d3e4d5b4ffdf374b836ec9d4d3e315040c8c3779John Reck Intent intent = new Intent(mActivity, ComboViewActivity.class); 513d3e4d5b4ffdf374b836ec9d4d3e315040c8c3779John Reck intent.putExtra(ComboViewActivity.EXTRA_INITIAL_VIEW, startingView.name()); 514d3e4d5b4ffdf374b836ec9d4d3e315040c8c3779John Reck intent.putExtra(ComboViewActivity.EXTRA_COMBO_ARGS, extras); 515d3e4d5b4ffdf374b836ec9d4d3e315040c8c3779John Reck Tab t = getActiveTab(); 516d3e4d5b4ffdf374b836ec9d4d3e315040c8c3779John Reck if (t != null) { 517d3e4d5b4ffdf374b836ec9d4d3e315040c8c3779John Reck intent.putExtra(ComboViewActivity.EXTRA_CURRENT_URL, t.getUrl()); 5183a696280cba53eea153c9d5707b236997d193328Michael Kolb } 519d3e4d5b4ffdf374b836ec9d4d3e315040c8c3779John Reck mActivity.startActivityForResult(intent, Controller.COMBO_VIEW); 5208233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 5218233facddcc51865d612a919d450db6954aa48e3Michael Kolb 5228233facddcc51865d612a919d450db6954aa48e3Michael Kolb @Override 5232d4f1e2553dee6bce5a12162ff6d4459babe2512Derek Sollenberger public void showCustomView(View view, int requestedOrientation, 5248233facddcc51865d612a919d450db6954aa48e3Michael Kolb WebChromeClient.CustomViewCallback callback) { 5258233facddcc51865d612a919d450db6954aa48e3Michael Kolb // if a view already exists then immediately terminate the new one 5268233facddcc51865d612a919d450db6954aa48e3Michael Kolb if (mCustomView != null) { 5278233facddcc51865d612a919d450db6954aa48e3Michael Kolb callback.onCustomViewHidden(); 5288233facddcc51865d612a919d450db6954aa48e3Michael Kolb return; 5298233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 5308233facddcc51865d612a919d450db6954aa48e3Michael Kolb 5312d4f1e2553dee6bce5a12162ff6d4459babe2512Derek Sollenberger mOriginalOrientation = mActivity.getRequestedOrientation(); 53231065b1940cb70ad131f20e29ad6250f7d09a290Michael Kolb FrameLayout decor = (FrameLayout) mActivity.getWindow().getDecorView(); 53331065b1940cb70ad131f20e29ad6250f7d09a290Michael Kolb mFullscreenContainer = new FullscreenHolder(mActivity); 53431065b1940cb70ad131f20e29ad6250f7d09a290Michael Kolb mFullscreenContainer.addView(view, COVER_SCREEN_PARAMS); 53531065b1940cb70ad131f20e29ad6250f7d09a290Michael Kolb decor.addView(mFullscreenContainer, COVER_SCREEN_PARAMS); 53631065b1940cb70ad131f20e29ad6250f7d09a290Michael Kolb mCustomView = view; 537c5675ad4baf34547770a98c7c0d8dec7f8fb4999Michael Kolb setFullscreen(true); 53854217b39d7d097f2f4fe9fac928a1c3bf1b9f13fMichael Kolb ((BrowserWebView) getWebView()).setVisibility(View.INVISIBLE); 5398233facddcc51865d612a919d450db6954aa48e3Michael Kolb mCustomViewCallback = callback; 5402d4f1e2553dee6bce5a12162ff6d4459babe2512Derek Sollenberger mActivity.setRequestedOrientation(requestedOrientation); 5418233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 5428233facddcc51865d612a919d450db6954aa48e3Michael Kolb 5438233facddcc51865d612a919d450db6954aa48e3Michael Kolb @Override 5448233facddcc51865d612a919d450db6954aa48e3Michael Kolb public void onHideCustomView() { 54554217b39d7d097f2f4fe9fac928a1c3bf1b9f13fMichael Kolb ((BrowserWebView) getWebView()).setVisibility(View.VISIBLE); 5468233facddcc51865d612a919d450db6954aa48e3Michael Kolb if (mCustomView == null) 5478233facddcc51865d612a919d450db6954aa48e3Michael Kolb return; 548c5675ad4baf34547770a98c7c0d8dec7f8fb4999Michael Kolb setFullscreen(false); 54931065b1940cb70ad131f20e29ad6250f7d09a290Michael Kolb FrameLayout decor = (FrameLayout) mActivity.getWindow().getDecorView(); 55031065b1940cb70ad131f20e29ad6250f7d09a290Michael Kolb decor.removeView(mFullscreenContainer); 55131065b1940cb70ad131f20e29ad6250f7d09a290Michael Kolb mFullscreenContainer = null; 5528233facddcc51865d612a919d450db6954aa48e3Michael Kolb mCustomView = null; 5538233facddcc51865d612a919d450db6954aa48e3Michael Kolb mCustomViewCallback.onCustomViewHidden(); 5548233facddcc51865d612a919d450db6954aa48e3Michael Kolb // Show the content view. 5552d4f1e2553dee6bce5a12162ff6d4459babe2512Derek Sollenberger mActivity.setRequestedOrientation(mOriginalOrientation); 5568233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 5578233facddcc51865d612a919d450db6954aa48e3Michael Kolb 5588233facddcc51865d612a919d450db6954aa48e3Michael Kolb @Override 5598233facddcc51865d612a919d450db6954aa48e3Michael Kolb public boolean isCustomViewShowing() { 5608233facddcc51865d612a919d450db6954aa48e3Michael Kolb return mCustomView != null; 5618233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 5628233facddcc51865d612a919d450db6954aa48e3Michael Kolb 5636670653d355fea0ae20dc51f6c693f994c4cbb54Michael Kolb protected void dismissIME() { 5643a696280cba53eea153c9d5707b236997d193328Michael Kolb if (mInputManager.isActive()) { 5653a696280cba53eea153c9d5707b236997d193328Michael Kolb mInputManager.hideSoftInputFromWindow(mContentView.getWindowToken(), 5663a696280cba53eea153c9d5707b236997d193328Michael Kolb 0); 5673a696280cba53eea153c9d5707b236997d193328Michael Kolb } 5683a696280cba53eea153c9d5707b236997d193328Michael Kolb } 5693a696280cba53eea153c9d5707b236997d193328Michael Kolb 5706670653d355fea0ae20dc51f6c693f994c4cbb54Michael Kolb @Override 5713ba455394dd3413b6246f00d2bf2083547862735John Reck public boolean isWebShowing() { 572d3e4d5b4ffdf374b836ec9d4d3e315040c8c3779John Reck return mCustomView == null; 5736670653d355fea0ae20dc51f6c693f994c4cbb54Michael Kolb } 5746670653d355fea0ae20dc51f6c693f994c4cbb54Michael Kolb 5759206677e461328f15854c5fcb1366d0e261534c6Patrick Scott @Override 5769206677e461328f15854c5fcb1366d0e261534c6Patrick Scott public void showAutoLogin(Tab tab) { 5779206677e461328f15854c5fcb1366d0e261534c6Patrick Scott updateAutoLogin(tab, true); 5789206677e461328f15854c5fcb1366d0e261534c6Patrick Scott } 5799206677e461328f15854c5fcb1366d0e261534c6Patrick Scott 5809206677e461328f15854c5fcb1366d0e261534c6Patrick Scott @Override 5819206677e461328f15854c5fcb1366d0e261534c6Patrick Scott public void hideAutoLogin(Tab tab) { 5829206677e461328f15854c5fcb1366d0e261534c6Patrick Scott updateAutoLogin(tab, true); 5839206677e461328f15854c5fcb1366d0e261534c6Patrick Scott } 5849206677e461328f15854c5fcb1366d0e261534c6Patrick Scott 5858233facddcc51865d612a919d450db6954aa48e3Michael Kolb // ------------------------------------------------------------------------- 5868233facddcc51865d612a919d450db6954aa48e3Michael Kolb 5875a72f1858c2f73be3558c6cdaa2c84b4c36fa748Michael Kolb protected void updateNavigationState(Tab tab) { 5885a72f1858c2f73be3558c6cdaa2c84b4c36fa748Michael Kolb } 5895a72f1858c2f73be3558c6cdaa2c84b4c36fa748Michael Kolb 59011d1978d8d16004598347abc93918b54a5ef760bMichael Kolb protected void updateAutoLogin(Tab tab, boolean animate) { 5910f602f3933dcd88702fdb514b6611e3066ca7a2bJohn Reck mTitleBar.updateAutoLogin(tab, animate); 59211d1978d8d16004598347abc93918b54a5ef760bMichael Kolb } 5939206677e461328f15854c5fcb1366d0e261534c6Patrick Scott 5948233facddcc51865d612a919d450db6954aa48e3Michael Kolb /** 5958233facddcc51865d612a919d450db6954aa48e3Michael Kolb * Update the lock icon to correspond to our latest state. 5968233facddcc51865d612a919d450db6954aa48e3Michael Kolb */ 5976670653d355fea0ae20dc51f6c693f994c4cbb54Michael Kolb protected void updateLockIconToLatest(Tab t) { 59830c714c853a4239e72ab1e238ce2a92472d06ab0John Reck if (t != null && t.inForeground()) { 5992466effd6ef97aa17396c214d51f9f19a4760260Steve Block updateLockIconImage(t.getSecurityState()); 6008233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 6018233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 6028233facddcc51865d612a919d450db6954aa48e3Michael Kolb 6038233facddcc51865d612a919d450db6954aa48e3Michael Kolb /** 6048233facddcc51865d612a919d450db6954aa48e3Michael Kolb * Updates the lock-icon image in the title-bar. 6058233facddcc51865d612a919d450db6954aa48e3Michael Kolb */ 6062466effd6ef97aa17396c214d51f9f19a4760260Steve Block private void updateLockIconImage(SecurityState securityState) { 6078233facddcc51865d612a919d450db6954aa48e3Michael Kolb Drawable d = null; 6082466effd6ef97aa17396c214d51f9f19a4760260Steve Block if (securityState == SecurityState.SECURITY_STATE_SECURE) { 6092466effd6ef97aa17396c214d51f9f19a4760260Steve Block d = mLockIconSecure; 6104895b0133c337a8d55bf7e9eac64fcecab4e3e79Steve Block } else if (securityState == SecurityState.SECURITY_STATE_MIXED 6114895b0133c337a8d55bf7e9eac64fcecab4e3e79Steve Block || securityState == SecurityState.SECURITY_STATE_BAD_CERTIFICATE) { 6124895b0133c337a8d55bf7e9eac64fcecab4e3e79Steve Block // TODO: It would be good to have different icons for insecure vs mixed content. 6134895b0133c337a8d55bf7e9eac64fcecab4e3e79Steve Block // See http://b/5403800 6142466effd6ef97aa17396c214d51f9f19a4760260Steve Block d = mLockIconMixed; 6158233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 6160f602f3933dcd88702fdb514b6611e3066ca7a2bJohn Reck mNavigationBar.setLock(d); 6178233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 6188233facddcc51865d612a919d450db6954aa48e3Michael Kolb 61930c714c853a4239e72ab1e238ce2a92472d06ab0John Reck protected void setUrlTitle(Tab tab) { 62030c714c853a4239e72ab1e238ce2a92472d06ab0John Reck String url = tab.getUrl(); 62130c714c853a4239e72ab1e238ce2a92472d06ab0John Reck String title = tab.getTitle(); 6226670653d355fea0ae20dc51f6c693f994c4cbb54Michael Kolb if (TextUtils.isEmpty(title)) { 6236670653d355fea0ae20dc51f6c693f994c4cbb54Michael Kolb title = url; 6246670653d355fea0ae20dc51f6c693f994c4cbb54Michael Kolb } 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 } 8552711fab2fa2eb798e3aea90368f7ac5af1fbe523John Reck 8562711fab2fa2eb798e3aea90368f7ac5af1fbe523John Reck public void addFixedTitleBar(View view) { 8572711fab2fa2eb798e3aea90368f7ac5af1fbe523John Reck mFixedTitlebarContainer.addView(view); 8582711fab2fa2eb798e3aea90368f7ac5af1fbe523John Reck } 8592711fab2fa2eb798e3aea90368f7ac5af1fbe523John Reck 8602711fab2fa2eb798e3aea90368f7ac5af1fbe523John Reck public void setContentViewMarginTop(int margin) { 8612711fab2fa2eb798e3aea90368f7ac5af1fbe523John Reck LinearLayout.LayoutParams params = 8622711fab2fa2eb798e3aea90368f7ac5af1fbe523John Reck (LinearLayout.LayoutParams) mContentView.getLayoutParams(); 8632711fab2fa2eb798e3aea90368f7ac5af1fbe523John Reck if (params.topMargin != margin) { 8642711fab2fa2eb798e3aea90368f7ac5af1fbe523John Reck params.topMargin = margin; 8652711fab2fa2eb798e3aea90368f7ac5af1fbe523John Reck mContentView.setLayoutParams(params); 8662711fab2fa2eb798e3aea90368f7ac5af1fbe523John Reck } 8672711fab2fa2eb798e3aea90368f7ac5af1fbe523John Reck } 868bae0cb200f6ad93ce61c5781100f4b6ac0cb6649Michael Kolb 869bae0cb200f6ad93ce61c5781100f4b6ac0cb6649Michael Kolb @Override 870bae0cb200f6ad93ce61c5781100f4b6ac0cb6649Michael Kolb public boolean blockFocusAnimations() { 871bae0cb200f6ad93ce61c5781100f4b6ac0cb6649Michael Kolb return mBlockFocusAnimations; 872bae0cb200f6ad93ce61c5781100f4b6ac0cb6649Michael Kolb } 873bae0cb200f6ad93ce61c5781100f4b6ac0cb6649Michael Kolb 8740b12912da64ff5b2917d4f50eb91df2e76457d08Michael Kolb @Override 8750b12912da64ff5b2917d4f50eb91df2e76457d08Michael Kolb public void onVoiceResult(String result) { 8760b12912da64ff5b2917d4f50eb91df2e76457d08Michael Kolb mNavigationBar.onVoiceResult(result); 8770b12912da64ff5b2917d4f50eb91df2e76457d08Michael Kolb } 8780b12912da64ff5b2917d4f50eb91df2e76457d08Michael Kolb 8798233facddcc51865d612a919d450db6954aa48e3Michael Kolb} 880