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; 498233facddcc51865d612a919d450db6954aa48e3Michael Kolbimport android.widget.FrameLayout; 501514bb7ed5656316a8dac966cee21653f3c59affMichael Kolbimport android.widget.ImageButton; 518233facddcc51865d612a919d450db6954aa48e3Michael Kolbimport android.widget.LinearLayout; 528233facddcc51865d612a919d450db6954aa48e3Michael Kolbimport android.widget.Toast; 538233facddcc51865d612a919d450db6954aa48e3Michael Kolb 542466effd6ef97aa17396c214d51f9f19a4760260Steve Blockimport com.android.browser.Tab.SecurityState; 55bf2ec206e8743467961da3e857b07aad6c50cd67John Reckimport com.android.internal.view.menu.MenuBuilder; 56bf2ec206e8743467961da3e857b07aad6c50cd67John Reck 571bf231334fd4bda8dbde5b9a0345c756a213b3a2Michael Kolbimport java.util.List; 581bf231334fd4bda8dbde5b9a0345c756a213b3a2Michael Kolb 598233facddcc51865d612a919d450db6954aa48e3Michael Kolb/** 608233facddcc51865d612a919d450db6954aa48e3Michael Kolb * UI interface definitions 618233facddcc51865d612a919d450db6954aa48e3Michael Kolb */ 62718a24d6c9671fe2da4112a3b5f30fd3939b38e8John Reckpublic abstract class BaseUi implements UI { 638233facddcc51865d612a919d450db6954aa48e3Michael Kolb 648233facddcc51865d612a919d450db6954aa48e3Michael Kolb private static final String LOGTAG = "BaseUi"; 658233facddcc51865d612a919d450db6954aa48e3Michael Kolb 666670653d355fea0ae20dc51f6c693f994c4cbb54Michael Kolb protected static final FrameLayout.LayoutParams COVER_SCREEN_PARAMS = 678233facddcc51865d612a919d450db6954aa48e3Michael Kolb new FrameLayout.LayoutParams( 688233facddcc51865d612a919d450db6954aa48e3Michael Kolb ViewGroup.LayoutParams.MATCH_PARENT, 698233facddcc51865d612a919d450db6954aa48e3Michael Kolb ViewGroup.LayoutParams.MATCH_PARENT); 708233facddcc51865d612a919d450db6954aa48e3Michael Kolb 716670653d355fea0ae20dc51f6c693f994c4cbb54Michael Kolb protected static final FrameLayout.LayoutParams COVER_SCREEN_GRAVITY_CENTER = 728233facddcc51865d612a919d450db6954aa48e3Michael Kolb new FrameLayout.LayoutParams( 738233facddcc51865d612a919d450db6954aa48e3Michael Kolb ViewGroup.LayoutParams.MATCH_PARENT, 748233facddcc51865d612a919d450db6954aa48e3Michael Kolb ViewGroup.LayoutParams.MATCH_PARENT, 758233facddcc51865d612a919d450db6954aa48e3Michael Kolb Gravity.CENTER); 768233facddcc51865d612a919d450db6954aa48e3Michael Kolb 775d43ce897758b7cb5deadc1203717b965334784cJohn Reck private static final int MSG_HIDE_TITLEBAR = 1; 78ef654f1dd80f55609060005342fc4f2cde62990cJohn Reck public static final int HIDE_TITLEBAR_DELAY = 1500; // in ms 795d43ce897758b7cb5deadc1203717b965334784cJohn Reck 808233facddcc51865d612a919d450db6954aa48e3Michael Kolb Activity mActivity; 818233facddcc51865d612a919d450db6954aa48e3Michael Kolb UiController mUiController; 828233facddcc51865d612a919d450db6954aa48e3Michael Kolb TabControl mTabControl; 83377ea31324391e7878f6f5b7a991c74988c18403Michael Kolb protected Tab mActiveTab; 843a696280cba53eea153c9d5707b236997d193328Michael Kolb private InputMethodManager mInputManager; 858233facddcc51865d612a919d450db6954aa48e3Michael Kolb 862466effd6ef97aa17396c214d51f9f19a4760260Steve Block private Drawable mLockIconSecure; 872466effd6ef97aa17396c214d51f9f19a4760260Steve Block private Drawable mLockIconMixed; 885a4372f4638f9a1fc5c052d85977fbcc0c4d8c55Michael Kolb protected Drawable mGenericFavicon; 898233facddcc51865d612a919d450db6954aa48e3Michael Kolb 906670653d355fea0ae20dc51f6c693f994c4cbb54Michael Kolb protected FrameLayout mContentView; 91f205560dacc8a85f0443ca1949a68962404321e8Michael Kolb protected FrameLayout mCustomViewContainer; 9231065b1940cb70ad131f20e29ad6250f7d09a290Michael Kolb protected FrameLayout mFullscreenContainer; 932711fab2fa2eb798e3aea90368f7ac5af1fbe523John Reck private FrameLayout mFixedTitlebarContainer; 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; 115bae0cb200f6ad93ce61c5781100f4b6ac0cb6649Michael Kolb private boolean mBlockFocusAnimations; 1168233facddcc51865d612a919d450db6954aa48e3Michael Kolb 1178233facddcc51865d612a919d450db6954aa48e3Michael Kolb public BaseUi(Activity browser, UiController controller) { 1188233facddcc51865d612a919d450db6954aa48e3Michael Kolb mActivity = browser; 1198233facddcc51865d612a919d450db6954aa48e3Michael Kolb mUiController = controller; 1208233facddcc51865d612a919d450db6954aa48e3Michael Kolb mTabControl = controller.getTabControl(); 1218233facddcc51865d612a919d450db6954aa48e3Michael Kolb Resources res = mActivity.getResources(); 1223a696280cba53eea153c9d5707b236997d193328Michael Kolb mInputManager = (InputMethodManager) 1233a696280cba53eea153c9d5707b236997d193328Michael Kolb browser.getSystemService(Activity.INPUT_METHOD_SERVICE); 1242466effd6ef97aa17396c214d51f9f19a4760260Steve Block mLockIconSecure = res.getDrawable(R.drawable.ic_secure_holo_dark); 1252466effd6ef97aa17396c214d51f9f19a4760260Steve Block mLockIconMixed = res.getDrawable(R.drawable.ic_secure_partial_holo_dark); 1268233facddcc51865d612a919d450db6954aa48e3Michael Kolb FrameLayout frameLayout = (FrameLayout) mActivity.getWindow() 1278233facddcc51865d612a919d450db6954aa48e3Michael Kolb .getDecorView().findViewById(android.R.id.content); 1287c6e1c928ea078034e7eacf32ef5c209138001d9John Reck LayoutInflater.from(mActivity) 1297c6e1c928ea078034e7eacf32ef5c209138001d9John Reck .inflate(R.layout.custom_screen, frameLayout); 1302711fab2fa2eb798e3aea90368f7ac5af1fbe523John Reck mFixedTitlebarContainer = (FrameLayout) frameLayout.findViewById( 1312711fab2fa2eb798e3aea90368f7ac5af1fbe523John Reck R.id.fixed_titlebar_container); 1327c6e1c928ea078034e7eacf32ef5c209138001d9John Reck mContentView = (FrameLayout) frameLayout.findViewById( 1338233facddcc51865d612a919d450db6954aa48e3Michael Kolb R.id.main_content); 13453ed62c0171fdbaecaccfbbb08cbf22cb08d39a5Michael Kolb mCustomViewContainer = (FrameLayout) frameLayout.findViewById( 13553ed62c0171fdbaecaccfbbb08cbf22cb08d39a5Michael Kolb R.id.fullscreen_custom_content); 1367c6e1c928ea078034e7eacf32ef5c209138001d9John Reck mErrorConsoleContainer = (LinearLayout) frameLayout 1378233facddcc51865d612a919d450db6954aa48e3Michael Kolb .findViewById(R.id.error_console); 138c38c604eca3bd0620cd9284187aace78455e723dMichael Kolb setFullscreen(BrowserSettings.getInstance().useFullscreen()); 1395a4372f4638f9a1fc5c052d85977fbcc0c4d8c55Michael Kolb mGenericFavicon = res.getDrawable( 1405a4372f4638f9a1fc5c052d85977fbcc0c4d8c55Michael Kolb R.drawable.app_web_browser_sm); 1410f602f3933dcd88702fdb514b6611e3066ca7a2bJohn Reck mTitleBar = new TitleBar(mActivity, mUiController, this, 1420f602f3933dcd88702fdb514b6611e3066ca7a2bJohn Reck mContentView); 1430f602f3933dcd88702fdb514b6611e3066ca7a2bJohn Reck mTitleBar.setProgress(100); 1440f602f3933dcd88702fdb514b6611e3066ca7a2bJohn Reck mNavigationBar = mTitleBar.getNavigationBar(); 145718a24d6c9671fe2da4112a3b5f30fd3939b38e8John Reck mUrlBarAutoShowManager = new UrlBarAutoShowManager(this); 1468233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 1478233facddcc51865d612a919d450db6954aa48e3Michael Kolb 1488233facddcc51865d612a919d450db6954aa48e3Michael Kolb private void cancelStopToast() { 1498233facddcc51865d612a919d450db6954aa48e3Michael Kolb if (mStopToast != null) { 1508233facddcc51865d612a919d450db6954aa48e3Michael Kolb mStopToast.cancel(); 1518233facddcc51865d612a919d450db6954aa48e3Michael Kolb mStopToast = null; 1528233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 1538233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 1548233facddcc51865d612a919d450db6954aa48e3Michael Kolb 1558233facddcc51865d612a919d450db6954aa48e3Michael Kolb // lifecycle 1568233facddcc51865d612a919d450db6954aa48e3Michael Kolb 1578233facddcc51865d612a919d450db6954aa48e3Michael Kolb public void onPause() { 1587a5cf4714453bd982afc662f373d0c38cddfb023Michael Kolb if (isCustomViewShowing()) { 1597a5cf4714453bd982afc662f373d0c38cddfb023Michael Kolb onHideCustomView(); 1607a5cf4714453bd982afc662f373d0c38cddfb023Michael Kolb } 1618233facddcc51865d612a919d450db6954aa48e3Michael Kolb cancelStopToast(); 1628233facddcc51865d612a919d450db6954aa48e3Michael Kolb mActivityPaused = true; 1638233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 1648233facddcc51865d612a919d450db6954aa48e3Michael Kolb 1658233facddcc51865d612a919d450db6954aa48e3Michael Kolb public void onResume() { 1668233facddcc51865d612a919d450db6954aa48e3Michael Kolb mActivityPaused = false; 1672ae6ef7f6c146a5bc3a4c7ef8de56505eb02399eMichael Kolb // check if we exited without setting active tab 1682ae6ef7f6c146a5bc3a4c7ef8de56505eb02399eMichael Kolb // b: 5188145 1691a4625a4fa1f3aae01de5cee5338ee4552edd3e8Michael Kolb final Tab ct = mTabControl.getCurrentTab(); 1701a4625a4fa1f3aae01de5cee5338ee4552edd3e8Michael Kolb if (ct != null) { 1711a4625a4fa1f3aae01de5cee5338ee4552edd3e8Michael Kolb setActiveTab(ct); 1721a4625a4fa1f3aae01de5cee5338ee4552edd3e8Michael Kolb } 1731cc1d1d08c50211e4f9f8407978d0435a0110375John Reck mTitleBar.onResume(); 1748233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 1758233facddcc51865d612a919d450db6954aa48e3Michael Kolb 1766670653d355fea0ae20dc51f6c693f994c4cbb54Michael Kolb protected boolean isActivityPaused() { 1776670653d355fea0ae20dc51f6c693f994c4cbb54Michael Kolb return mActivityPaused; 1788233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 1798233facddcc51865d612a919d450db6954aa48e3Michael Kolb 1808233facddcc51865d612a919d450db6954aa48e3Michael Kolb public void onConfigurationChanged(Configuration config) { 1818233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 1828233facddcc51865d612a919d450db6954aa48e3Michael Kolb 1830f602f3933dcd88702fdb514b6611e3066ca7a2bJohn Reck public Activity getActivity() { 1840f602f3933dcd88702fdb514b6611e3066ca7a2bJohn Reck return mActivity; 1850f602f3933dcd88702fdb514b6611e3066ca7a2bJohn Reck } 1860f602f3933dcd88702fdb514b6611e3066ca7a2bJohn Reck 1878233facddcc51865d612a919d450db6954aa48e3Michael Kolb // key handling 1888233facddcc51865d612a919d450db6954aa48e3Michael Kolb 1898233facddcc51865d612a919d450db6954aa48e3Michael Kolb @Override 1908233facddcc51865d612a919d450db6954aa48e3Michael Kolb public boolean onBackKey() { 1918233facddcc51865d612a919d450db6954aa48e3Michael Kolb if (mCustomView != null) { 1928233facddcc51865d612a919d450db6954aa48e3Michael Kolb mUiController.hideCustomView(); 1938233facddcc51865d612a919d450db6954aa48e3Michael Kolb return true; 1948233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 1958233facddcc51865d612a919d450db6954aa48e3Michael Kolb return false; 1968233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 1978233facddcc51865d612a919d450db6954aa48e3Michael Kolb 1982814a362c21ac219410d9b54e1bd3e8152b845c7Michael Kolb @Override 1992814a362c21ac219410d9b54e1bd3e8152b845c7Michael Kolb public boolean onMenuKey() { 2002814a362c21ac219410d9b54e1bd3e8152b845c7Michael Kolb return false; 2012814a362c21ac219410d9b54e1bd3e8152b845c7Michael Kolb } 2022814a362c21ac219410d9b54e1bd3e8152b845c7Michael Kolb 203da580634265a0add98d3c16b07103edbe724a5b3Michael Kolb @Override 204da580634265a0add98d3c16b07103edbe724a5b3Michael Kolb public void setUseQuickControls(boolean useQuickControls) { 205da580634265a0add98d3c16b07103edbe724a5b3Michael Kolb mUseQuickControls = useQuickControls; 206da580634265a0add98d3c16b07103edbe724a5b3Michael Kolb mTitleBar.setUseQuickControls(mUseQuickControls); 207da580634265a0add98d3c16b07103edbe724a5b3Michael Kolb if (useQuickControls) { 208da580634265a0add98d3c16b07103edbe724a5b3Michael Kolb mPieControl = new PieControl(mActivity, mUiController, this); 209da580634265a0add98d3c16b07103edbe724a5b3Michael Kolb mPieControl.attachToContainer(mContentView); 210da580634265a0add98d3c16b07103edbe724a5b3Michael Kolb } else { 211da580634265a0add98d3c16b07103edbe724a5b3Michael Kolb if (mPieControl != null) { 212da580634265a0add98d3c16b07103edbe724a5b3Michael Kolb mPieControl.removeFromContainer(mContentView); 213da580634265a0add98d3c16b07103edbe724a5b3Michael Kolb } 214da580634265a0add98d3c16b07103edbe724a5b3Michael Kolb } 215da580634265a0add98d3c16b07103edbe724a5b3Michael Kolb updateUrlBarAutoShowManagerTarget(); 216da580634265a0add98d3c16b07103edbe724a5b3Michael Kolb } 217da580634265a0add98d3c16b07103edbe724a5b3Michael Kolb 21830c714c853a4239e72ab1e238ce2a92472d06ab0John Reck // Tab callbacks 2198233facddcc51865d612a919d450db6954aa48e3Michael Kolb @Override 22030c714c853a4239e72ab1e238ce2a92472d06ab0John Reck public void onTabDataChanged(Tab tab) { 22130c714c853a4239e72ab1e238ce2a92472d06ab0John Reck setUrlTitle(tab); 22230c714c853a4239e72ab1e238ce2a92472d06ab0John Reck setFavicon(tab); 22330c714c853a4239e72ab1e238ce2a92472d06ab0John Reck updateLockIconToLatest(tab); 2245a72f1858c2f73be3558c6cdaa2c84b4c36fa748Michael Kolb updateNavigationState(tab); 225ef654f1dd80f55609060005342fc4f2cde62990cJohn Reck mTitleBar.onTabDataChanged(tab); 226419f6b4136a8fac758e2159f223700b1dfcc20e2John Reck mNavigationBar.onTabDataChanged(tab); 227a53c98902be0f9f959b6af06227254e5ad2130c9Michael Kolb onProgressChanged(tab); 2288233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 2298233facddcc51865d612a919d450db6954aa48e3Michael Kolb 2308233facddcc51865d612a919d450db6954aa48e3Michael Kolb @Override 231e8a823329e004c4261ee5f810e1ca3ebd90914ddMichael Kolb public void onProgressChanged(Tab tab) { 232e8a823329e004c4261ee5f810e1ca3ebd90914ddMichael Kolb int progress = tab.getLoadProgress(); 233e8a823329e004c4261ee5f810e1ca3ebd90914ddMichael Kolb if (tab.inForeground()) { 234e8a823329e004c4261ee5f810e1ca3ebd90914ddMichael Kolb mTitleBar.setProgress(progress); 235e8a823329e004c4261ee5f810e1ca3ebd90914ddMichael Kolb } 236e8a823329e004c4261ee5f810e1ca3ebd90914ddMichael Kolb } 237e8a823329e004c4261ee5f810e1ca3ebd90914ddMichael Kolb 238e8a823329e004c4261ee5f810e1ca3ebd90914ddMichael Kolb @Override 2394cd97793901e8f5681cf642d0b2684697964a37aLeon Scroggins public void bookmarkedStatusHasChanged(Tab tab) { 24094b7e04932d77d73f348efecf7f2dd6b4ee5e5a1John Reck if (tab.inForeground()) { 24194b7e04932d77d73f348efecf7f2dd6b4ee5e5a1John Reck boolean isBookmark = tab.isBookmarkedSite(); 2420f602f3933dcd88702fdb514b6611e3066ca7a2bJohn Reck mNavigationBar.setCurrentUrlIsBookmark(isBookmark); 24394b7e04932d77d73f348efecf7f2dd6b4ee5e5a1John Reck } 2444cd97793901e8f5681cf642d0b2684697964a37aLeon Scroggins } 2454cd97793901e8f5681cf642d0b2684697964a37aLeon Scroggins 2464cd97793901e8f5681cf642d0b2684697964a37aLeon Scroggins @Override 2478233facddcc51865d612a919d450db6954aa48e3Michael Kolb public void onPageStopped(Tab tab) { 2488233facddcc51865d612a919d450db6954aa48e3Michael Kolb cancelStopToast(); 2498233facddcc51865d612a919d450db6954aa48e3Michael Kolb if (tab.inForeground()) { 2508233facddcc51865d612a919d450db6954aa48e3Michael Kolb mStopToast = Toast 2518233facddcc51865d612a919d450db6954aa48e3Michael Kolb .makeText(mActivity, R.string.stopping, Toast.LENGTH_SHORT); 2528233facddcc51865d612a919d450db6954aa48e3Michael Kolb mStopToast.show(); 2538233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 2548233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 2558233facddcc51865d612a919d450db6954aa48e3Michael Kolb 2568233facddcc51865d612a919d450db6954aa48e3Michael Kolb @Override 2571bf231334fd4bda8dbde5b9a0345c756a213b3a2Michael Kolb public boolean needsRestoreAllTabs() { 258847b532045e3cb117a847ebb956c9919401f332dJohn Reck return true; 2591bf231334fd4bda8dbde5b9a0345c756a213b3a2Michael Kolb } 2601bf231334fd4bda8dbde5b9a0345c756a213b3a2Michael Kolb 2611bf231334fd4bda8dbde5b9a0345c756a213b3a2Michael Kolb @Override 2628233facddcc51865d612a919d450db6954aa48e3Michael Kolb public void addTab(Tab tab) { 2638233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 2648233facddcc51865d612a919d450db6954aa48e3Michael Kolb 2658233facddcc51865d612a919d450db6954aa48e3Michael Kolb @Override 266377ea31324391e7878f6f5b7a991c74988c18403Michael Kolb public void setActiveTab(final Tab tab) { 2677ac63b64e9f127057f93b12fb65400c5a6dee7c4Michael Kolb if (tab == null) return; 268bae0cb200f6ad93ce61c5781100f4b6ac0cb6649Michael Kolb // block unnecessary focus change animations during tab switch 269bae0cb200f6ad93ce61c5781100f4b6ac0cb6649Michael Kolb mBlockFocusAnimations = true; 2705d43ce897758b7cb5deadc1203717b965334784cJohn Reck mHandler.removeMessages(MSG_HIDE_TITLEBAR); 27177df4568331d527f993f4d69168218ddf5acdddaMichael Kolb if ((tab != mActiveTab) && (mActiveTab != null)) { 27277df4568331d527f993f4d69168218ddf5acdddaMichael Kolb removeTabFromContentView(mActiveTab); 273bf2ec206e8743467961da3e857b07aad6c50cd67John Reck WebView web = mActiveTab.getWebView(); 274bf2ec206e8743467961da3e857b07aad6c50cd67John Reck if (web != null) { 275bf2ec206e8743467961da3e857b07aad6c50cd67John Reck web.setOnTouchListener(null); 276bf2ec206e8743467961da3e857b07aad6c50cd67John Reck } 2778233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 27877df4568331d527f993f4d69168218ddf5acdddaMichael Kolb mActiveTab = tab; 279da580634265a0add98d3c16b07103edbe724a5b3Michael Kolb BrowserWebView web = (BrowserWebView) mActiveTab.getWebView(); 280718a24d6c9671fe2da4112a3b5f30fd3939b38e8John Reck updateUrlBarAutoShowManagerTarget(); 2815d43ce897758b7cb5deadc1203717b965334784cJohn Reck attachTabToContentView(tab); 282da580634265a0add98d3c16b07103edbe724a5b3Michael Kolb if (web != null) { 283da580634265a0add98d3c16b07103edbe724a5b3Michael Kolb // Request focus on the top window. 284da580634265a0add98d3c16b07103edbe724a5b3Michael Kolb if (mUseQuickControls) { 285da580634265a0add98d3c16b07103edbe724a5b3Michael Kolb mPieControl.forceToTop(mContentView); 286da580634265a0add98d3c16b07103edbe724a5b3Michael Kolb web.setTitleBar(null); 287e8a823329e004c4261ee5f810e1ca3ebd90914ddMichael Kolb mTitleBar.hide(); 288da580634265a0add98d3c16b07103edbe724a5b3Michael Kolb } else { 289da580634265a0add98d3c16b07103edbe724a5b3Michael Kolb web.setTitleBar(mTitleBar); 290da580634265a0add98d3c16b07103edbe724a5b3Michael Kolb mTitleBar.onScrollChanged(); 291da580634265a0add98d3c16b07103edbe724a5b3Michael Kolb } 292da580634265a0add98d3c16b07103edbe724a5b3Michael Kolb } 2934923c22cb79296a9624a599cf8874323cdbc6cbcMichael Kolb mTitleBar.bringToFront(); 294f8963521024f39236388eb8e70835f813bf7f4eeMichael Kolb tab.getTopWindow().requestFocus(); 2958233facddcc51865d612a919d450db6954aa48e3Michael Kolb setShouldShowErrorConsole(tab, mUiController.shouldShowErrorConsole()); 29630c714c853a4239e72ab1e238ce2a92472d06ab0John Reck onTabDataChanged(tab); 29730c714c853a4239e72ab1e238ce2a92472d06ab0John Reck onProgressChanged(tab); 29803b6bc6dc3644e9843f2ff05bca543e546fe3a61Michael Kolb mNavigationBar.setIncognitoMode(tab.isPrivateBrowsingEnabled()); 2999206677e461328f15854c5fcb1366d0e261534c6Patrick Scott updateAutoLogin(tab, false); 300bae0cb200f6ad93ce61c5781100f4b6ac0cb6649Michael Kolb mBlockFocusAnimations = false; 3018233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 3028233facddcc51865d612a919d450db6954aa48e3Michael Kolb 303718a24d6c9671fe2da4112a3b5f30fd3939b38e8John Reck protected void updateUrlBarAutoShowManagerTarget() { 304718a24d6c9671fe2da4112a3b5f30fd3939b38e8John Reck WebView web = mActiveTab != null ? mActiveTab.getWebView() : null; 305718a24d6c9671fe2da4112a3b5f30fd3939b38e8John Reck if (!mUseQuickControls && web instanceof BrowserWebView) { 306718a24d6c9671fe2da4112a3b5f30fd3939b38e8John Reck mUrlBarAutoShowManager.setTarget((BrowserWebView) web); 307718a24d6c9671fe2da4112a3b5f30fd3939b38e8John Reck } else { 308718a24d6c9671fe2da4112a3b5f30fd3939b38e8John Reck mUrlBarAutoShowManager.setTarget(null); 309718a24d6c9671fe2da4112a3b5f30fd3939b38e8John Reck } 310718a24d6c9671fe2da4112a3b5f30fd3939b38e8John Reck } 311718a24d6c9671fe2da4112a3b5f30fd3939b38e8John Reck 312cfa3af5c59abb38c895416a80ef16da0ec1b5287Michael Kolb Tab getActiveTab() { 313cfa3af5c59abb38c895416a80ef16da0ec1b5287Michael Kolb return mActiveTab; 314cfa3af5c59abb38c895416a80ef16da0ec1b5287Michael Kolb } 315cfa3af5c59abb38c895416a80ef16da0ec1b5287Michael Kolb 3168233facddcc51865d612a919d450db6954aa48e3Michael Kolb @Override 3171bf231334fd4bda8dbde5b9a0345c756a213b3a2Michael Kolb public void updateTabs(List<Tab> tabs) { 3181bf231334fd4bda8dbde5b9a0345c756a213b3a2Michael Kolb } 3191bf231334fd4bda8dbde5b9a0345c756a213b3a2Michael Kolb 3201bf231334fd4bda8dbde5b9a0345c756a213b3a2Michael Kolb @Override 3218233facddcc51865d612a919d450db6954aa48e3Michael Kolb public void removeTab(Tab tab) { 32277df4568331d527f993f4d69168218ddf5acdddaMichael Kolb if (mActiveTab == tab) { 3238233facddcc51865d612a919d450db6954aa48e3Michael Kolb removeTabFromContentView(tab); 32477df4568331d527f993f4d69168218ddf5acdddaMichael Kolb mActiveTab = null; 3258233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 3268233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 3278233facddcc51865d612a919d450db6954aa48e3Michael Kolb 3288233facddcc51865d612a919d450db6954aa48e3Michael Kolb @Override 3298233facddcc51865d612a919d450db6954aa48e3Michael Kolb public void detachTab(Tab tab) { 3308233facddcc51865d612a919d450db6954aa48e3Michael Kolb removeTabFromContentView(tab); 3318233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 3328233facddcc51865d612a919d450db6954aa48e3Michael Kolb 3338233facddcc51865d612a919d450db6954aa48e3Michael Kolb @Override 3348233facddcc51865d612a919d450db6954aa48e3Michael Kolb public void attachTab(Tab tab) { 3358233facddcc51865d612a919d450db6954aa48e3Michael Kolb attachTabToContentView(tab); 3368233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 3378233facddcc51865d612a919d450db6954aa48e3Michael Kolb 338377ea31324391e7878f6f5b7a991c74988c18403Michael Kolb protected void attachTabToContentView(Tab tab) { 339d1e2ccc38a2d5318a4ab06b2349cb43303fd6cebMichael Kolb if ((tab == null) || (tab.getWebView() == null)) { 3408233facddcc51865d612a919d450db6954aa48e3Michael Kolb return; 3418233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 3428233facddcc51865d612a919d450db6954aa48e3Michael Kolb View container = tab.getViewContainer(); 3438233facddcc51865d612a919d450db6954aa48e3Michael Kolb WebView mainView = tab.getWebView(); 3448233facddcc51865d612a919d450db6954aa48e3Michael Kolb // Attach the WebView to the container and then attach the 3458233facddcc51865d612a919d450db6954aa48e3Michael Kolb // container to the content view. 3468233facddcc51865d612a919d450db6954aa48e3Michael Kolb FrameLayout wrapper = 3478233facddcc51865d612a919d450db6954aa48e3Michael Kolb (FrameLayout) container.findViewById(R.id.webview_wrapper); 3488233facddcc51865d612a919d450db6954aa48e3Michael Kolb ViewGroup parent = (ViewGroup) mainView.getParent(); 3498233facddcc51865d612a919d450db6954aa48e3Michael Kolb if (parent != wrapper) { 3508233facddcc51865d612a919d450db6954aa48e3Michael Kolb if (parent != null) { 3518233facddcc51865d612a919d450db6954aa48e3Michael Kolb parent.removeView(mainView); 3528233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 3538233facddcc51865d612a919d450db6954aa48e3Michael Kolb wrapper.addView(mainView); 3548233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 3558233facddcc51865d612a919d450db6954aa48e3Michael Kolb parent = (ViewGroup) container.getParent(); 3568233facddcc51865d612a919d450db6954aa48e3Michael Kolb if (parent != mContentView) { 3578233facddcc51865d612a919d450db6954aa48e3Michael Kolb if (parent != null) { 3588233facddcc51865d612a919d450db6954aa48e3Michael Kolb parent.removeView(container); 3598233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 3608233facddcc51865d612a919d450db6954aa48e3Michael Kolb mContentView.addView(container, COVER_SCREEN_PARAMS); 3618233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 3628233facddcc51865d612a919d450db6954aa48e3Michael Kolb mUiController.attachSubWindow(tab); 3638233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 3648233facddcc51865d612a919d450db6954aa48e3Michael Kolb 3658233facddcc51865d612a919d450db6954aa48e3Michael Kolb private void removeTabFromContentView(Tab tab) { 3667cdc4906fc5852297a9a254c3251ad2f4dead6eeMichael Kolb hideTitleBar(); 3678233facddcc51865d612a919d450db6954aa48e3Michael Kolb // Remove the container that contains the main WebView. 3688233facddcc51865d612a919d450db6954aa48e3Michael Kolb WebView mainView = tab.getWebView(); 3698233facddcc51865d612a919d450db6954aa48e3Michael Kolb View container = tab.getViewContainer(); 3708233facddcc51865d612a919d450db6954aa48e3Michael Kolb if (mainView == null) { 3718233facddcc51865d612a919d450db6954aa48e3Michael Kolb return; 3728233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 3738233facddcc51865d612a919d450db6954aa48e3Michael Kolb // Remove the container from the content and then remove the 3748233facddcc51865d612a919d450db6954aa48e3Michael Kolb // WebView from the container. This will trigger a focus change 3758233facddcc51865d612a919d450db6954aa48e3Michael Kolb // needed by WebView. 3768233facddcc51865d612a919d450db6954aa48e3Michael Kolb FrameLayout wrapper = 3778233facddcc51865d612a919d450db6954aa48e3Michael Kolb (FrameLayout) container.findViewById(R.id.webview_wrapper); 3788233facddcc51865d612a919d450db6954aa48e3Michael Kolb wrapper.removeView(mainView); 3798233facddcc51865d612a919d450db6954aa48e3Michael Kolb mContentView.removeView(container); 3808233facddcc51865d612a919d450db6954aa48e3Michael Kolb mUiController.endActionMode(); 3818233facddcc51865d612a919d450db6954aa48e3Michael Kolb mUiController.removeSubWindow(tab); 3828233facddcc51865d612a919d450db6954aa48e3Michael Kolb ErrorConsoleView errorConsole = tab.getErrorConsole(false); 3838233facddcc51865d612a919d450db6954aa48e3Michael Kolb if (errorConsole != null) { 3848233facddcc51865d612a919d450db6954aa48e3Michael Kolb mErrorConsoleContainer.removeView(errorConsole); 3858233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 3868233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 3878233facddcc51865d612a919d450db6954aa48e3Michael Kolb 388a713ec8cc9da6c0c8078cd297c6240eb8bf01bbbMichael Kolb @Override 389a713ec8cc9da6c0c8078cd297c6240eb8bf01bbbMichael Kolb public void onSetWebView(Tab tab, WebView webView) { 390a713ec8cc9da6c0c8078cd297c6240eb8bf01bbbMichael Kolb View container = tab.getViewContainer(); 391a713ec8cc9da6c0c8078cd297c6240eb8bf01bbbMichael Kolb if (container == null) { 392a713ec8cc9da6c0c8078cd297c6240eb8bf01bbbMichael Kolb // The tab consists of a container view, which contains the main 393a713ec8cc9da6c0c8078cd297c6240eb8bf01bbbMichael Kolb // WebView, as well as any other UI elements associated with the tab. 394a713ec8cc9da6c0c8078cd297c6240eb8bf01bbbMichael Kolb container = mActivity.getLayoutInflater().inflate(R.layout.tab, 3957c6e1c928ea078034e7eacf32ef5c209138001d9John Reck mContentView, false); 396a713ec8cc9da6c0c8078cd297c6240eb8bf01bbbMichael Kolb tab.setViewContainer(container); 397a713ec8cc9da6c0c8078cd297c6240eb8bf01bbbMichael Kolb } 398a713ec8cc9da6c0c8078cd297c6240eb8bf01bbbMichael Kolb if (tab.getWebView() != webView) { 399a713ec8cc9da6c0c8078cd297c6240eb8bf01bbbMichael Kolb // Just remove the old one. 400a713ec8cc9da6c0c8078cd297c6240eb8bf01bbbMichael Kolb FrameLayout wrapper = 401a713ec8cc9da6c0c8078cd297c6240eb8bf01bbbMichael Kolb (FrameLayout) container.findViewById(R.id.webview_wrapper); 402a713ec8cc9da6c0c8078cd297c6240eb8bf01bbbMichael Kolb wrapper.removeView(tab.getWebView()); 403a713ec8cc9da6c0c8078cd297c6240eb8bf01bbbMichael Kolb } 404a713ec8cc9da6c0c8078cd297c6240eb8bf01bbbMichael Kolb } 405a713ec8cc9da6c0c8078cd297c6240eb8bf01bbbMichael Kolb 4068233facddcc51865d612a919d450db6954aa48e3Michael Kolb /** 4071514bb7ed5656316a8dac966cee21653f3c59affMichael Kolb * create a sub window container and webview for the tab 4081514bb7ed5656316a8dac966cee21653f3c59affMichael Kolb * Note: this methods operates through side-effects for now 4091514bb7ed5656316a8dac966cee21653f3c59affMichael Kolb * it sets both the subView and subViewContainer for the given tab 4101514bb7ed5656316a8dac966cee21653f3c59affMichael Kolb * @param tab tab to create the sub window for 4111514bb7ed5656316a8dac966cee21653f3c59affMichael Kolb * @param subView webview to be set as a subwindow for the tab 4121514bb7ed5656316a8dac966cee21653f3c59affMichael Kolb */ 4131514bb7ed5656316a8dac966cee21653f3c59affMichael Kolb @Override 4141514bb7ed5656316a8dac966cee21653f3c59affMichael Kolb public void createSubWindow(Tab tab, WebView subView) { 4151514bb7ed5656316a8dac966cee21653f3c59affMichael Kolb View subViewContainer = mActivity.getLayoutInflater().inflate( 4161514bb7ed5656316a8dac966cee21653f3c59affMichael Kolb R.layout.browser_subwindow, null); 4171514bb7ed5656316a8dac966cee21653f3c59affMichael Kolb ViewGroup inner = (ViewGroup) subViewContainer 4181514bb7ed5656316a8dac966cee21653f3c59affMichael Kolb .findViewById(R.id.inner_container); 4191514bb7ed5656316a8dac966cee21653f3c59affMichael Kolb inner.addView(subView, new LayoutParams(LayoutParams.MATCH_PARENT, 4201514bb7ed5656316a8dac966cee21653f3c59affMichael Kolb LayoutParams.MATCH_PARENT)); 4211514bb7ed5656316a8dac966cee21653f3c59affMichael Kolb final ImageButton cancel = (ImageButton) subViewContainer 4221514bb7ed5656316a8dac966cee21653f3c59affMichael Kolb .findViewById(R.id.subwindow_close); 4231514bb7ed5656316a8dac966cee21653f3c59affMichael Kolb final WebView cancelSubView = subView; 4241514bb7ed5656316a8dac966cee21653f3c59affMichael Kolb cancel.setOnClickListener(new OnClickListener() { 425e1d6dfca80e4627a0c7fe46e38f904179c3edab3Jonathan Dixon @Override 4261514bb7ed5656316a8dac966cee21653f3c59affMichael Kolb public void onClick(View v) { 427e1d6dfca80e4627a0c7fe46e38f904179c3edab3Jonathan Dixon ((BrowserWebView) cancelSubView).getWebChromeClient().onCloseWindow(cancelSubView); 4281514bb7ed5656316a8dac966cee21653f3c59affMichael Kolb } 4291514bb7ed5656316a8dac966cee21653f3c59affMichael Kolb }); 4301514bb7ed5656316a8dac966cee21653f3c59affMichael Kolb tab.setSubWebView(subView); 4311514bb7ed5656316a8dac966cee21653f3c59affMichael Kolb tab.setSubViewContainer(subViewContainer); 4321514bb7ed5656316a8dac966cee21653f3c59affMichael Kolb } 4331514bb7ed5656316a8dac966cee21653f3c59affMichael Kolb 4341514bb7ed5656316a8dac966cee21653f3c59affMichael Kolb /** 4358233facddcc51865d612a919d450db6954aa48e3Michael Kolb * Remove the sub window from the content view. 4368233facddcc51865d612a919d450db6954aa48e3Michael Kolb */ 4378233facddcc51865d612a919d450db6954aa48e3Michael Kolb @Override 4388233facddcc51865d612a919d450db6954aa48e3Michael Kolb public void removeSubWindow(View subviewContainer) { 4398233facddcc51865d612a919d450db6954aa48e3Michael Kolb mContentView.removeView(subviewContainer); 4408233facddcc51865d612a919d450db6954aa48e3Michael Kolb mUiController.endActionMode(); 4418233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 4428233facddcc51865d612a919d450db6954aa48e3Michael Kolb 4438233facddcc51865d612a919d450db6954aa48e3Michael Kolb /** 4448233facddcc51865d612a919d450db6954aa48e3Michael Kolb * Attach the sub window to the content view. 4458233facddcc51865d612a919d450db6954aa48e3Michael Kolb */ 4468233facddcc51865d612a919d450db6954aa48e3Michael Kolb @Override 4478233facddcc51865d612a919d450db6954aa48e3Michael Kolb public void attachSubWindow(View container) { 4481514bb7ed5656316a8dac966cee21653f3c59affMichael Kolb if (container.getParent() != null) { 4491514bb7ed5656316a8dac966cee21653f3c59affMichael Kolb // already attached, remove first 4501514bb7ed5656316a8dac966cee21653f3c59affMichael Kolb ((ViewGroup) container.getParent()).removeView(container); 4511514bb7ed5656316a8dac966cee21653f3c59affMichael Kolb } 4528233facddcc51865d612a919d450db6954aa48e3Michael Kolb mContentView.addView(container, COVER_SCREEN_PARAMS); 4538233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 4548233facddcc51865d612a919d450db6954aa48e3Michael Kolb 45511d1978d8d16004598347abc93918b54a5ef760bMichael Kolb protected void refreshWebView() { 45646f987eca738a36e2c8382aaec6c7ef2ae2482aeMichael Kolb WebView web = getWebView(); 45746f987eca738a36e2c8382aaec6c7ef2ae2482aeMichael Kolb if (web != null) { 45846f987eca738a36e2c8382aaec6c7ef2ae2482aeMichael Kolb web.invalidate(); 45946f987eca738a36e2c8382aaec6c7ef2ae2482aeMichael Kolb } 46046f987eca738a36e2c8382aaec6c7ef2ae2482aeMichael Kolb } 46146f987eca738a36e2c8382aaec6c7ef2ae2482aeMichael Kolb 4621f9b3565dbd1911dfe4d9bfd8b833a5ac5f2e0c4Michael Kolb public void editUrl(boolean clearInput, boolean forceIME) { 46346f987eca738a36e2c8382aaec6c7ef2ae2482aeMichael Kolb if (mUiController.isInCustomActionMode()) { 46446f987eca738a36e2c8382aaec6c7ef2ae2482aeMichael Kolb mUiController.endActionMode(); 46511d1978d8d16004598347abc93918b54a5ef760bMichael Kolb } 46646f987eca738a36e2c8382aaec6c7ef2ae2482aeMichael Kolb showTitleBar(); 467ace2ff88b860c60c634d6cd49177eb4c5413228bMichael Kolb if ((getActiveTab() != null) && !getActiveTab().isSnapshot()) { 4681f9b3565dbd1911dfe4d9bfd8b833a5ac5f2e0c4Michael Kolb mNavigationBar.startEditingUrl(clearInput, forceIME); 469ef654f1dd80f55609060005342fc4f2cde62990cJohn Reck } 47011d1978d8d16004598347abc93918b54a5ef760bMichael Kolb } 47111d1978d8d16004598347abc93918b54a5ef760bMichael Kolb 4727cdc4906fc5852297a9a254c3251ad2f4dead6eeMichael Kolb boolean canShowTitleBar() { 4737cdc4906fc5852297a9a254c3251ad2f4dead6eeMichael Kolb return !isTitleBarShowing() 4747cdc4906fc5852297a9a254c3251ad2f4dead6eeMichael Kolb && !isActivityPaused() 4757cdc4906fc5852297a9a254c3251ad2f4dead6eeMichael Kolb && (getActiveTab() != null) 47646f987eca738a36e2c8382aaec6c7ef2ae2482aeMichael Kolb && (getWebView() != null) 4777cdc4906fc5852297a9a254c3251ad2f4dead6eeMichael Kolb && !mUiController.isInCustomActionMode(); 4788233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 4798233facddcc51865d612a919d450db6954aa48e3Michael Kolb 4800f602f3933dcd88702fdb514b6611e3066ca7a2bJohn Reck protected void showTitleBar() { 481ef654f1dd80f55609060005342fc4f2cde62990cJohn Reck mHandler.removeMessages(MSG_HIDE_TITLEBAR); 48246f987eca738a36e2c8382aaec6c7ef2ae2482aeMichael Kolb if (canShowTitleBar()) { 4830f602f3933dcd88702fdb514b6611e3066ca7a2bJohn Reck mTitleBar.show(); 48446f987eca738a36e2c8382aaec6c7ef2ae2482aeMichael Kolb } 4857cdc4906fc5852297a9a254c3251ad2f4dead6eeMichael Kolb } 4866670653d355fea0ae20dc51f6c693f994c4cbb54Michael Kolb 4877cdc4906fc5852297a9a254c3251ad2f4dead6eeMichael Kolb protected void hideTitleBar() { 4880f602f3933dcd88702fdb514b6611e3066ca7a2bJohn Reck if (mTitleBar.isShowing()) { 4890f602f3933dcd88702fdb514b6611e3066ca7a2bJohn Reck mTitleBar.hide(); 49046f987eca738a36e2c8382aaec6c7ef2ae2482aeMichael Kolb } 4917cdc4906fc5852297a9a254c3251ad2f4dead6eeMichael Kolb } 4926670653d355fea0ae20dc51f6c693f994c4cbb54Michael Kolb 4937cdc4906fc5852297a9a254c3251ad2f4dead6eeMichael Kolb protected boolean isTitleBarShowing() { 4940f602f3933dcd88702fdb514b6611e3066ca7a2bJohn Reck return mTitleBar.isShowing(); 4957cdc4906fc5852297a9a254c3251ad2f4dead6eeMichael Kolb } 4966670653d355fea0ae20dc51f6c693f994c4cbb54Michael Kolb 4975d43ce897758b7cb5deadc1203717b965334784cJohn Reck public boolean isEditingUrl() { 4980f602f3933dcd88702fdb514b6611e3066ca7a2bJohn Reck return mTitleBar.isEditingUrl(); 4995d43ce897758b7cb5deadc1203717b965334784cJohn Reck } 5005d43ce897758b7cb5deadc1203717b965334784cJohn Reck 50180f750852edf43c6b09e5633f2c6ebdb2ed94a5bMichael Kolb public void stopEditingUrl() { 50280f750852edf43c6b09e5633f2c6ebdb2ed94a5bMichael Kolb mTitleBar.getNavigationBar().stopEditingUrl(); 50380f750852edf43c6b09e5633f2c6ebdb2ed94a5bMichael Kolb } 50480f750852edf43c6b09e5633f2c6ebdb2ed94a5bMichael Kolb 5050f602f3933dcd88702fdb514b6611e3066ca7a2bJohn Reck public TitleBar getTitleBar() { 5060f602f3933dcd88702fdb514b6611e3066ca7a2bJohn Reck return mTitleBar; 5070f602f3933dcd88702fdb514b6611e3066ca7a2bJohn Reck } 5086670653d355fea0ae20dc51f6c693f994c4cbb54Michael Kolb 5096670653d355fea0ae20dc51f6c693f994c4cbb54Michael Kolb @Override 5102bc8042224be51966d748b870768ec1b376a1621John Reck public void showComboView(ComboViews startingView, Bundle extras) { 511d3e4d5b4ffdf374b836ec9d4d3e315040c8c3779John Reck Intent intent = new Intent(mActivity, ComboViewActivity.class); 512d3e4d5b4ffdf374b836ec9d4d3e315040c8c3779John Reck intent.putExtra(ComboViewActivity.EXTRA_INITIAL_VIEW, startingView.name()); 513d3e4d5b4ffdf374b836ec9d4d3e315040c8c3779John Reck intent.putExtra(ComboViewActivity.EXTRA_COMBO_ARGS, extras); 514d3e4d5b4ffdf374b836ec9d4d3e315040c8c3779John Reck Tab t = getActiveTab(); 515d3e4d5b4ffdf374b836ec9d4d3e315040c8c3779John Reck if (t != null) { 516d3e4d5b4ffdf374b836ec9d4d3e315040c8c3779John Reck intent.putExtra(ComboViewActivity.EXTRA_CURRENT_URL, t.getUrl()); 5173a696280cba53eea153c9d5707b236997d193328Michael Kolb } 518d3e4d5b4ffdf374b836ec9d4d3e315040c8c3779John Reck mActivity.startActivityForResult(intent, Controller.COMBO_VIEW); 5198233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 5208233facddcc51865d612a919d450db6954aa48e3Michael Kolb 5218233facddcc51865d612a919d450db6954aa48e3Michael Kolb @Override 5222d4f1e2553dee6bce5a12162ff6d4459babe2512Derek Sollenberger public void showCustomView(View view, int requestedOrientation, 5238233facddcc51865d612a919d450db6954aa48e3Michael Kolb WebChromeClient.CustomViewCallback callback) { 5248233facddcc51865d612a919d450db6954aa48e3Michael Kolb // if a view already exists then immediately terminate the new one 5258233facddcc51865d612a919d450db6954aa48e3Michael Kolb if (mCustomView != null) { 5268233facddcc51865d612a919d450db6954aa48e3Michael Kolb callback.onCustomViewHidden(); 5278233facddcc51865d612a919d450db6954aa48e3Michael Kolb return; 5288233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 5298233facddcc51865d612a919d450db6954aa48e3Michael Kolb 5302d4f1e2553dee6bce5a12162ff6d4459babe2512Derek Sollenberger mOriginalOrientation = mActivity.getRequestedOrientation(); 53131065b1940cb70ad131f20e29ad6250f7d09a290Michael Kolb FrameLayout decor = (FrameLayout) mActivity.getWindow().getDecorView(); 53231065b1940cb70ad131f20e29ad6250f7d09a290Michael Kolb mFullscreenContainer = new FullscreenHolder(mActivity); 53331065b1940cb70ad131f20e29ad6250f7d09a290Michael Kolb mFullscreenContainer.addView(view, COVER_SCREEN_PARAMS); 53431065b1940cb70ad131f20e29ad6250f7d09a290Michael Kolb decor.addView(mFullscreenContainer, COVER_SCREEN_PARAMS); 53531065b1940cb70ad131f20e29ad6250f7d09a290Michael Kolb mCustomView = view; 536c5675ad4baf34547770a98c7c0d8dec7f8fb4999Michael Kolb setFullscreen(true); 53754217b39d7d097f2f4fe9fac928a1c3bf1b9f13fMichael Kolb ((BrowserWebView) getWebView()).setVisibility(View.INVISIBLE); 5388233facddcc51865d612a919d450db6954aa48e3Michael Kolb mCustomViewCallback = callback; 5392d4f1e2553dee6bce5a12162ff6d4459babe2512Derek Sollenberger mActivity.setRequestedOrientation(requestedOrientation); 5408233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 5418233facddcc51865d612a919d450db6954aa48e3Michael Kolb 5428233facddcc51865d612a919d450db6954aa48e3Michael Kolb @Override 5438233facddcc51865d612a919d450db6954aa48e3Michael Kolb public void onHideCustomView() { 54454217b39d7d097f2f4fe9fac928a1c3bf1b9f13fMichael Kolb ((BrowserWebView) getWebView()).setVisibility(View.VISIBLE); 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.inForeground()) { 6250f602f3933dcd88702fdb514b6611e3066ca7a2bJohn Reck mNavigationBar.setDisplayTitle(url); 6266670653d355fea0ae20dc51f6c693f994c4cbb54Michael Kolb } 6278233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 6288233facddcc51865d612a919d450db6954aa48e3Michael Kolb 6296670653d355fea0ae20dc51f6c693f994c4cbb54Michael Kolb // Set the favicon in the title bar. 63030c714c853a4239e72ab1e238ce2a92472d06ab0John Reck protected void setFavicon(Tab tab) { 63130c714c853a4239e72ab1e238ce2a92472d06ab0John Reck if (tab.inForeground()) { 63230c714c853a4239e72ab1e238ce2a92472d06ab0John Reck Bitmap icon = tab.getFavicon(); 6330f602f3933dcd88702fdb514b6611e3066ca7a2bJohn Reck mNavigationBar.setFavicon(icon); 63430c714c853a4239e72ab1e238ce2a92472d06ab0John Reck } 6358233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 6368233facddcc51865d612a919d450db6954aa48e3Michael Kolb 6378233facddcc51865d612a919d450db6954aa48e3Michael Kolb @Override 6388233facddcc51865d612a919d450db6954aa48e3Michael Kolb public void onActionModeFinished(boolean inLoad) { 6398233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 6408233facddcc51865d612a919d450db6954aa48e3Michael Kolb 6416670653d355fea0ae20dc51f6c693f994c4cbb54Michael Kolb // active tabs page 6426670653d355fea0ae20dc51f6c693f994c4cbb54Michael Kolb 6436670653d355fea0ae20dc51f6c693f994c4cbb54Michael Kolb public void showActiveTabsPage() { 6446670653d355fea0ae20dc51f6c693f994c4cbb54Michael Kolb } 6456670653d355fea0ae20dc51f6c693f994c4cbb54Michael Kolb 6466670653d355fea0ae20dc51f6c693f994c4cbb54Michael Kolb /** 6476670653d355fea0ae20dc51f6c693f994c4cbb54Michael Kolb * Remove the active tabs page. 6486670653d355fea0ae20dc51f6c693f994c4cbb54Michael Kolb */ 6496670653d355fea0ae20dc51f6c693f994c4cbb54Michael Kolb public void removeActiveTabsPage() { 6506670653d355fea0ae20dc51f6c693f994c4cbb54Michael Kolb } 6516670653d355fea0ae20dc51f6c693f994c4cbb54Michael Kolb 6528233facddcc51865d612a919d450db6954aa48e3Michael Kolb // menu handling callbacks 6538233facddcc51865d612a919d450db6954aa48e3Michael Kolb 6548233facddcc51865d612a919d450db6954aa48e3Michael Kolb @Override 6551acef69ffc079d1bc029ff7eb1f5043f7efd7f36Michael Kolb public boolean onPrepareOptionsMenu(Menu menu) { 6561acef69ffc079d1bc029ff7eb1f5043f7efd7f36Michael Kolb return true; 6571acef69ffc079d1bc029ff7eb1f5043f7efd7f36Michael Kolb } 6581acef69ffc079d1bc029ff7eb1f5043f7efd7f36Michael Kolb 6591acef69ffc079d1bc029ff7eb1f5043f7efd7f36Michael Kolb @Override 6607bdee0b303d8969aace4d3e43be5bb9f16e276bfMichael Kolb public void updateMenuState(Tab tab, Menu menu) { 6617bdee0b303d8969aace4d3e43be5bb9f16e276bfMichael Kolb } 6627bdee0b303d8969aace4d3e43be5bb9f16e276bfMichael Kolb 6637bdee0b303d8969aace4d3e43be5bb9f16e276bfMichael Kolb @Override 6648233facddcc51865d612a919d450db6954aa48e3Michael Kolb public void onOptionsMenuOpened() { 6658233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 6668233facddcc51865d612a919d450db6954aa48e3Michael Kolb 6678233facddcc51865d612a919d450db6954aa48e3Michael Kolb @Override 6688233facddcc51865d612a919d450db6954aa48e3Michael Kolb public void onExtendedMenuOpened() { 6698233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 6708233facddcc51865d612a919d450db6954aa48e3Michael Kolb 6718233facddcc51865d612a919d450db6954aa48e3Michael Kolb @Override 6723ca12750f9b6231b00a1856dcb25c2d2e07e8784Michael Kolb public boolean onOptionsItemSelected(MenuItem item) { 6733ca12750f9b6231b00a1856dcb25c2d2e07e8784Michael Kolb return false; 6743ca12750f9b6231b00a1856dcb25c2d2e07e8784Michael Kolb } 6753ca12750f9b6231b00a1856dcb25c2d2e07e8784Michael Kolb 6763ca12750f9b6231b00a1856dcb25c2d2e07e8784Michael Kolb @Override 6778233facddcc51865d612a919d450db6954aa48e3Michael Kolb public void onOptionsMenuClosed(boolean inLoad) { 6788233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 6798233facddcc51865d612a919d450db6954aa48e3Michael Kolb 6808233facddcc51865d612a919d450db6954aa48e3Michael Kolb @Override 6818233facddcc51865d612a919d450db6954aa48e3Michael Kolb public void onExtendedMenuClosed(boolean inLoad) { 6828233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 6838233facddcc51865d612a919d450db6954aa48e3Michael Kolb 6848233facddcc51865d612a919d450db6954aa48e3Michael Kolb @Override 6858233facddcc51865d612a919d450db6954aa48e3Michael Kolb public void onContextMenuCreated(Menu menu) { 6868233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 6878233facddcc51865d612a919d450db6954aa48e3Michael Kolb 6888233facddcc51865d612a919d450db6954aa48e3Michael Kolb @Override 6898233facddcc51865d612a919d450db6954aa48e3Michael Kolb public void onContextMenuClosed(Menu menu, boolean inLoad) { 6908233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 6918233facddcc51865d612a919d450db6954aa48e3Michael Kolb 6928233facddcc51865d612a919d450db6954aa48e3Michael Kolb // error console 6938233facddcc51865d612a919d450db6954aa48e3Michael Kolb 6948233facddcc51865d612a919d450db6954aa48e3Michael Kolb @Override 6958233facddcc51865d612a919d450db6954aa48e3Michael Kolb public void setShouldShowErrorConsole(Tab tab, boolean flag) { 6969fcefd19ee20ec9f792ddc84be9a871550e82997Michael Kolb if (tab == null) return; 6978233facddcc51865d612a919d450db6954aa48e3Michael Kolb ErrorConsoleView errorConsole = tab.getErrorConsole(true); 6988233facddcc51865d612a919d450db6954aa48e3Michael Kolb if (flag) { 6998233facddcc51865d612a919d450db6954aa48e3Michael Kolb // Setting the show state of the console will cause it's the layout 7008233facddcc51865d612a919d450db6954aa48e3Michael Kolb // to be inflated. 7018233facddcc51865d612a919d450db6954aa48e3Michael Kolb if (errorConsole.numberOfErrors() > 0) { 7028233facddcc51865d612a919d450db6954aa48e3Michael Kolb errorConsole.showConsole(ErrorConsoleView.SHOW_MINIMIZED); 7038233facddcc51865d612a919d450db6954aa48e3Michael Kolb } else { 7048233facddcc51865d612a919d450db6954aa48e3Michael Kolb errorConsole.showConsole(ErrorConsoleView.SHOW_NONE); 7058233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 7068233facddcc51865d612a919d450db6954aa48e3Michael Kolb if (errorConsole.getParent() != null) { 7078233facddcc51865d612a919d450db6954aa48e3Michael Kolb mErrorConsoleContainer.removeView(errorConsole); 7088233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 7098233facddcc51865d612a919d450db6954aa48e3Michael Kolb // Now we can add it to the main view. 7108233facddcc51865d612a919d450db6954aa48e3Michael Kolb mErrorConsoleContainer.addView(errorConsole, 7118233facddcc51865d612a919d450db6954aa48e3Michael Kolb new LinearLayout.LayoutParams( 7128233facddcc51865d612a919d450db6954aa48e3Michael Kolb ViewGroup.LayoutParams.MATCH_PARENT, 7138233facddcc51865d612a919d450db6954aa48e3Michael Kolb ViewGroup.LayoutParams.WRAP_CONTENT)); 7148233facddcc51865d612a919d450db6954aa48e3Michael Kolb } else { 7158233facddcc51865d612a919d450db6954aa48e3Michael Kolb mErrorConsoleContainer.removeView(errorConsole); 7168233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 7178233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 7188233facddcc51865d612a919d450db6954aa48e3Michael Kolb 7198233facddcc51865d612a919d450db6954aa48e3Michael Kolb // ------------------------------------------------------------------------- 7208233facddcc51865d612a919d450db6954aa48e3Michael Kolb // Helper function for WebChromeClient 7218233facddcc51865d612a919d450db6954aa48e3Michael Kolb // ------------------------------------------------------------------------- 7228233facddcc51865d612a919d450db6954aa48e3Michael Kolb 7238233facddcc51865d612a919d450db6954aa48e3Michael Kolb @Override 7248233facddcc51865d612a919d450db6954aa48e3Michael Kolb public Bitmap getDefaultVideoPoster() { 7258233facddcc51865d612a919d450db6954aa48e3Michael Kolb if (mDefaultVideoPoster == null) { 7268233facddcc51865d612a919d450db6954aa48e3Michael Kolb mDefaultVideoPoster = BitmapFactory.decodeResource( 7278233facddcc51865d612a919d450db6954aa48e3Michael Kolb mActivity.getResources(), R.drawable.default_video_poster); 7288233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 7298233facddcc51865d612a919d450db6954aa48e3Michael Kolb return mDefaultVideoPoster; 7308233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 7318233facddcc51865d612a919d450db6954aa48e3Michael Kolb 7328233facddcc51865d612a919d450db6954aa48e3Michael Kolb @Override 7338233facddcc51865d612a919d450db6954aa48e3Michael Kolb public View getVideoLoadingProgressView() { 7348233facddcc51865d612a919d450db6954aa48e3Michael Kolb if (mVideoProgressView == null) { 7358233facddcc51865d612a919d450db6954aa48e3Michael Kolb LayoutInflater inflater = LayoutInflater.from(mActivity); 7368233facddcc51865d612a919d450db6954aa48e3Michael Kolb mVideoProgressView = inflater.inflate( 7378233facddcc51865d612a919d450db6954aa48e3Michael Kolb R.layout.video_loading_progress, null); 7388233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 7398233facddcc51865d612a919d450db6954aa48e3Michael Kolb return mVideoProgressView; 7408233facddcc51865d612a919d450db6954aa48e3Michael Kolb } 7418233facddcc51865d612a919d450db6954aa48e3Michael Kolb 742843510fb4f36a9a834c69d8773156db20ca3d740Michael Kolb @Override 743843510fb4f36a9a834c69d8773156db20ca3d740Michael Kolb public void showMaxTabsWarning() { 744843510fb4f36a9a834c69d8773156db20ca3d740Michael Kolb Toast warning = Toast.makeText(mActivity, 745843510fb4f36a9a834c69d8773156db20ca3d740Michael Kolb mActivity.getString(R.string.max_tabs_warning), 746843510fb4f36a9a834c69d8773156db20ca3d740Michael Kolb Toast.LENGTH_SHORT); 747843510fb4f36a9a834c69d8773156db20ca3d740Michael Kolb warning.show(); 748843510fb4f36a9a834c69d8773156db20ca3d740Michael Kolb } 749843510fb4f36a9a834c69d8773156db20ca3d740Michael Kolb 75046f987eca738a36e2c8382aaec6c7ef2ae2482aeMichael Kolb protected WebView getWebView() { 75146f987eca738a36e2c8382aaec6c7ef2ae2482aeMichael Kolb if (mActiveTab != null) { 75246f987eca738a36e2c8382aaec6c7ef2ae2482aeMichael Kolb return mActiveTab.getWebView(); 75346f987eca738a36e2c8382aaec6c7ef2ae2482aeMichael Kolb } else { 75446f987eca738a36e2c8382aaec6c7ef2ae2482aeMichael Kolb return null; 75546f987eca738a36e2c8382aaec6c7ef2ae2482aeMichael Kolb } 756fdb7024334dffd63273eb9c424260b5fe633b94dMichael Kolb } 757fdb7024334dffd63273eb9c424260b5fe633b94dMichael Kolb 758fedb492d1ac1068e17028b6d4083d1a6b0578287Michael Kolb protected Menu getMenu() { 759fedb492d1ac1068e17028b6d4083d1a6b0578287Michael Kolb MenuBuilder menu = new MenuBuilder(mActivity); 760fedb492d1ac1068e17028b6d4083d1a6b0578287Michael Kolb mActivity.getMenuInflater().inflate(R.menu.browser, menu); 761fedb492d1ac1068e17028b6d4083d1a6b0578287Michael Kolb return menu; 762fedb492d1ac1068e17028b6d4083d1a6b0578287Michael Kolb } 763fedb492d1ac1068e17028b6d4083d1a6b0578287Michael Kolb 764c38c604eca3bd0620cd9284187aace78455e723dMichael Kolb public void setFullscreen(boolean enabled) { 765c5675ad4baf34547770a98c7c0d8dec7f8fb4999Michael Kolb Window win = mActivity.getWindow(); 766c5675ad4baf34547770a98c7c0d8dec7f8fb4999Michael Kolb WindowManager.LayoutParams winParams = win.getAttributes(); 76776dff39b75c73d2ab059a731866b84400704e196Michael Kolb final int bits = WindowManager.LayoutParams.FLAG_FULLSCREEN; 768c38c604eca3bd0620cd9284187aace78455e723dMichael Kolb if (enabled) { 769c5675ad4baf34547770a98c7c0d8dec7f8fb4999Michael Kolb winParams.flags |= bits; 770c38c604eca3bd0620cd9284187aace78455e723dMichael Kolb } else { 771c5675ad4baf34547770a98c7c0d8dec7f8fb4999Michael Kolb winParams.flags &= ~bits; 772c5675ad4baf34547770a98c7c0d8dec7f8fb4999Michael Kolb if (mCustomView != null) { 773c5675ad4baf34547770a98c7c0d8dec7f8fb4999Michael Kolb mCustomView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_VISIBLE); 774c5675ad4baf34547770a98c7c0d8dec7f8fb4999Michael Kolb } else { 775c5675ad4baf34547770a98c7c0d8dec7f8fb4999Michael Kolb mContentView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_VISIBLE); 776c5675ad4baf34547770a98c7c0d8dec7f8fb4999Michael Kolb } 777c38c604eca3bd0620cd9284187aace78455e723dMichael Kolb } 778c5675ad4baf34547770a98c7c0d8dec7f8fb4999Michael Kolb win.setAttributes(winParams); 779c38c604eca3bd0620cd9284187aace78455e723dMichael Kolb } 780c38c604eca3bd0620cd9284187aace78455e723dMichael Kolb 7810f602f3933dcd88702fdb514b6611e3066ca7a2bJohn Reck public Drawable getFaviconDrawable(Bitmap icon) { 7825a4372f4638f9a1fc5c052d85977fbcc0c4d8c55Michael Kolb Drawable[] array = new Drawable[3]; 7835a4372f4638f9a1fc5c052d85977fbcc0c4d8c55Michael Kolb array[0] = new PaintDrawable(Color.BLACK); 7845a4372f4638f9a1fc5c052d85977fbcc0c4d8c55Michael Kolb PaintDrawable p = new PaintDrawable(Color.WHITE); 7855a4372f4638f9a1fc5c052d85977fbcc0c4d8c55Michael Kolb array[1] = p; 7865a4372f4638f9a1fc5c052d85977fbcc0c4d8c55Michael Kolb if (icon == null) { 7875a4372f4638f9a1fc5c052d85977fbcc0c4d8c55Michael Kolb array[2] = mGenericFavicon; 7885a4372f4638f9a1fc5c052d85977fbcc0c4d8c55Michael Kolb } else { 7895a4372f4638f9a1fc5c052d85977fbcc0c4d8c55Michael Kolb array[2] = new BitmapDrawable(icon); 7905a4372f4638f9a1fc5c052d85977fbcc0c4d8c55Michael Kolb } 7915a4372f4638f9a1fc5c052d85977fbcc0c4d8c55Michael Kolb LayerDrawable d = new LayerDrawable(array); 7925a4372f4638f9a1fc5c052d85977fbcc0c4d8c55Michael Kolb d.setLayerInset(1, 1, 1, 1, 1); 7935a4372f4638f9a1fc5c052d85977fbcc0c4d8c55Michael Kolb d.setLayerInset(2, 2, 2, 2, 2); 7945a4372f4638f9a1fc5c052d85977fbcc0c4d8c55Michael Kolb return d; 7955a4372f4638f9a1fc5c052d85977fbcc0c4d8c55Michael Kolb } 7965a4372f4638f9a1fc5c052d85977fbcc0c4d8c55Michael Kolb 7975d43ce897758b7cb5deadc1203717b965334784cJohn Reck public boolean isLoading() { 7985d43ce897758b7cb5deadc1203717b965334784cJohn Reck return mActiveTab != null ? mActiveTab.inPageLoad() : false; 7995d43ce897758b7cb5deadc1203717b965334784cJohn Reck } 8005d43ce897758b7cb5deadc1203717b965334784cJohn Reck 8015d43ce897758b7cb5deadc1203717b965334784cJohn Reck /** 8025d43ce897758b7cb5deadc1203717b965334784cJohn Reck * Suggest to the UI that the title bar can be hidden. The UI will then 8035d43ce897758b7cb5deadc1203717b965334784cJohn Reck * decide whether or not to hide based off a number of factors, such 8045d43ce897758b7cb5deadc1203717b965334784cJohn Reck * as if the user is editing the URL bar or if the page is loading 8055d43ce897758b7cb5deadc1203717b965334784cJohn Reck */ 8065d43ce897758b7cb5deadc1203717b965334784cJohn Reck public void suggestHideTitleBar() { 80758891907e3cf77b72f1107ef5d9f4c984cb176edJohn Reck if (!isLoading() && !isEditingUrl() && !mTitleBar.wantsToBeVisible() 80858891907e3cf77b72f1107ef5d9f4c984cb176edJohn Reck && !mNavigationBar.isMenuShowing()) { 8095d43ce897758b7cb5deadc1203717b965334784cJohn Reck hideTitleBar(); 8105d43ce897758b7cb5deadc1203717b965334784cJohn Reck } 8115d43ce897758b7cb5deadc1203717b965334784cJohn Reck } 8125d43ce897758b7cb5deadc1203717b965334784cJohn Reck 813bc6adb4501853dbaba1c3bb592a159ee901b70e7John Reck protected final void showTitleBarForDuration() { 814bc6adb4501853dbaba1c3bb592a159ee901b70e7John Reck showTitleBarForDuration(HIDE_TITLEBAR_DELAY); 815bc6adb4501853dbaba1c3bb592a159ee901b70e7John Reck } 816bc6adb4501853dbaba1c3bb592a159ee901b70e7John Reck 817bc6adb4501853dbaba1c3bb592a159ee901b70e7John Reck protected final void showTitleBarForDuration(long duration) { 8186ac5bfda1a372219e469d965e94899d3b4895e0fJohn Reck showTitleBar(); 8196ac5bfda1a372219e469d965e94899d3b4895e0fJohn Reck Message msg = Message.obtain(mHandler, MSG_HIDE_TITLEBAR); 820bc6adb4501853dbaba1c3bb592a159ee901b70e7John Reck mHandler.sendMessageDelayed(msg, duration); 8216ac5bfda1a372219e469d965e94899d3b4895e0fJohn Reck } 8226ac5bfda1a372219e469d965e94899d3b4895e0fJohn Reck 8239c5004e6d5645cdf32fff3a3f04817a307b84dd6John Reck protected Handler mHandler = new Handler() { 8245d43ce897758b7cb5deadc1203717b965334784cJohn Reck 8255d43ce897758b7cb5deadc1203717b965334784cJohn Reck @Override 8265d43ce897758b7cb5deadc1203717b965334784cJohn Reck public void handleMessage(Message msg) { 8275d43ce897758b7cb5deadc1203717b965334784cJohn Reck if (msg.what == MSG_HIDE_TITLEBAR) { 8285d43ce897758b7cb5deadc1203717b965334784cJohn Reck suggestHideTitleBar(); 8295d43ce897758b7cb5deadc1203717b965334784cJohn Reck } 8309c5004e6d5645cdf32fff3a3f04817a307b84dd6John Reck BaseUi.this.handleMessage(msg); 8315d43ce897758b7cb5deadc1203717b965334784cJohn Reck } 8325d43ce897758b7cb5deadc1203717b965334784cJohn Reck }; 8333ba455394dd3413b6246f00d2bf2083547862735John Reck 8349c5004e6d5645cdf32fff3a3f04817a307b84dd6John Reck protected void handleMessage(Message msg) {} 8359c5004e6d5645cdf32fff3a3f04817a307b84dd6John Reck 8363ba455394dd3413b6246f00d2bf2083547862735John Reck @Override 8373ba455394dd3413b6246f00d2bf2083547862735John Reck public void showWeb(boolean animate) { 8383ba455394dd3413b6246f00d2bf2083547862735John Reck mUiController.hideCustomView(); 8393ba455394dd3413b6246f00d2bf2083547862735John Reck } 8403ba455394dd3413b6246f00d2bf2083547862735John Reck 84131065b1940cb70ad131f20e29ad6250f7d09a290Michael Kolb static class FullscreenHolder extends FrameLayout { 84253ed62c0171fdbaecaccfbbb08cbf22cb08d39a5Michael Kolb 84331065b1940cb70ad131f20e29ad6250f7d09a290Michael Kolb public FullscreenHolder(Context ctx) { 84431065b1940cb70ad131f20e29ad6250f7d09a290Michael Kolb super(ctx); 84531065b1940cb70ad131f20e29ad6250f7d09a290Michael Kolb setBackgroundColor(ctx.getResources().getColor(R.color.black)); 84653ed62c0171fdbaecaccfbbb08cbf22cb08d39a5Michael Kolb } 84753ed62c0171fdbaecaccfbbb08cbf22cb08d39a5Michael Kolb 84831065b1940cb70ad131f20e29ad6250f7d09a290Michael Kolb @Override 84931065b1940cb70ad131f20e29ad6250f7d09a290Michael Kolb public boolean onTouchEvent(MotionEvent evt) { 85031065b1940cb70ad131f20e29ad6250f7d09a290Michael Kolb return true; 85153ed62c0171fdbaecaccfbbb08cbf22cb08d39a5Michael Kolb } 85253ed62c0171fdbaecaccfbbb08cbf22cb08d39a5Michael Kolb 85331065b1940cb70ad131f20e29ad6250f7d09a290Michael Kolb } 8542711fab2fa2eb798e3aea90368f7ac5af1fbe523John Reck 8552711fab2fa2eb798e3aea90368f7ac5af1fbe523John Reck public void addFixedTitleBar(View view) { 8562711fab2fa2eb798e3aea90368f7ac5af1fbe523John Reck mFixedTitlebarContainer.addView(view); 8572711fab2fa2eb798e3aea90368f7ac5af1fbe523John Reck } 8582711fab2fa2eb798e3aea90368f7ac5af1fbe523John Reck 8592711fab2fa2eb798e3aea90368f7ac5af1fbe523John Reck public void setContentViewMarginTop(int margin) { 8602711fab2fa2eb798e3aea90368f7ac5af1fbe523John Reck LinearLayout.LayoutParams params = 8612711fab2fa2eb798e3aea90368f7ac5af1fbe523John Reck (LinearLayout.LayoutParams) mContentView.getLayoutParams(); 8622711fab2fa2eb798e3aea90368f7ac5af1fbe523John Reck if (params.topMargin != margin) { 8632711fab2fa2eb798e3aea90368f7ac5af1fbe523John Reck params.topMargin = margin; 8642711fab2fa2eb798e3aea90368f7ac5af1fbe523John Reck mContentView.setLayoutParams(params); 8652711fab2fa2eb798e3aea90368f7ac5af1fbe523John Reck } 8662711fab2fa2eb798e3aea90368f7ac5af1fbe523John Reck } 867bae0cb200f6ad93ce61c5781100f4b6ac0cb6649Michael Kolb 868bae0cb200f6ad93ce61c5781100f4b6ac0cb6649Michael Kolb @Override 869bae0cb200f6ad93ce61c5781100f4b6ac0cb6649Michael Kolb public boolean blockFocusAnimations() { 870bae0cb200f6ad93ce61c5781100f4b6ac0cb6649Michael Kolb return mBlockFocusAnimations; 871bae0cb200f6ad93ce61c5781100f4b6ac0cb6649Michael Kolb } 872bae0cb200f6ad93ce61c5781100f4b6ac0cb6649Michael Kolb 8730b12912da64ff5b2917d4f50eb91df2e76457d08Michael Kolb @Override 8740b12912da64ff5b2917d4f50eb91df2e76457d08Michael Kolb public void onVoiceResult(String result) { 8750b12912da64ff5b2917d4f50eb91df2e76457d08Michael Kolb mNavigationBar.onVoiceResult(result); 8760b12912da64ff5b2917d4f50eb91df2e76457d08Michael Kolb } 8770b12912da64ff5b2917d4f50eb91df2e76457d08Michael Kolb 8788233facddcc51865d612a919d450db6954aa48e3Michael Kolb} 879