Move Find on page and Select into the framework.

Bug: 2938052

Depends on a change to frameworks/base

Change-Id: I28db6d06fa248913091455e82853ef151a0561b0
diff --git a/res/drawable-hdpi/ic_btn_find_next.png b/res/drawable-hdpi/ic_btn_find_next.png
deleted file mode 100644
index b696a6b..0000000
--- a/res/drawable-hdpi/ic_btn_find_next.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-hdpi/ic_btn_find_prev.png b/res/drawable-hdpi/ic_btn_find_prev.png
deleted file mode 100644
index 5550c5a..0000000
--- a/res/drawable-hdpi/ic_btn_find_prev.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-hdpi/ic_menu_find.png b/res/drawable-hdpi/ic_menu_find.png
deleted file mode 100644
index 17ac694..0000000
--- a/res/drawable-hdpi/ic_menu_find.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/ic_btn_find_next.png b/res/drawable-mdpi/ic_btn_find_next.png
deleted file mode 100644
index abdc247..0000000
--- a/res/drawable-mdpi/ic_btn_find_next.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/ic_btn_find_prev.png b/res/drawable-mdpi/ic_btn_find_prev.png
deleted file mode 100644
index 4e3da1d..0000000
--- a/res/drawable-mdpi/ic_btn_find_prev.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/ic_menu_find.png b/res/drawable-mdpi/ic_menu_find.png
deleted file mode 100644
index 4d96348..0000000
--- a/res/drawable-mdpi/ic_menu_find.png
+++ /dev/null
Binary files differ
diff --git a/res/layout/bookmarkwidget.xml b/res/layout/bookmarkwidget.xml
index 2416e4f..c7c2a90 100644
--- a/res/layout/bookmarkwidget.xml
+++ b/res/layout/bookmarkwidget.xml
@@ -31,7 +31,7 @@
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
             android:padding="10dip"
-            android:src="@drawable/ic_btn_find_prev" />
+            android:src="@*android:drawable/ic_btn_find_prev" />
 
         <TextView
             android:id="@+id/title"
@@ -49,7 +49,7 @@
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
             android:padding="10dip"
-            android:src="@drawable/ic_btn_find_next" />
+            android:src="@*android:drawable/ic_btn_find_next" />
 
     </LinearLayout>
 
diff --git a/res/layout/browser_find.xml b/res/layout/browser_find.xml
deleted file mode 100644
index bb7a36f..0000000
--- a/res/layout/browser_find.xml
+++ /dev/null
@@ -1,40 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2007 The Android Open Source Project
-
-     Licensed under the Apache License, Version 2.0 (the "License");
-     you may not use this file except in compliance with the License.
-     You may obtain a copy of the License at
-
-          http://www.apache.org/licenses/LICENSE-2.0
-
-     Unless required by applicable law or agreed to in writing, software
-     distributed under the License is distributed on an "AS IS" BASIS,
-     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-     See the License for the specific language governing permissions and
-     limitations under the License.
--->
-
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
-    android:layout_width="match_parent"
-    android:layout_height="wrap_content"
-    android:orientation="horizontal"
-    >
-    <EditText android:id="@+id/edit"
-        android:layout_width="0dip"
-        android:layout_weight="1"
-        android:layout_height="wrap_content"
-        android:scrollHorizontally="true"
-        android:inputType="text"
-        android:hint="@string/find_dot"
-        android:imeOptions="actionDone"
-        android:layout_marginRight="10dip"
-        />
-    <TextView android:id="@+id/matches"
-        android:layout_width="wrap_content"
-        android:layout_height="wrap_content"
-        android:layout_gravity="center_vertical"
-        android:textAppearance="?android:attr/textAppearanceSmall"
-        android:textColor="?android:attr/textColorSecondaryInverse"
-        />
-</LinearLayout>	
-
diff --git a/res/menu-xlarge/browser.xml b/res/menu-xlarge/browser.xml
index 36e10d0..12a8a13 100644
--- a/res/menu-xlarge/browser.xml
+++ b/res/menu-xlarge/browser.xml
@@ -25,8 +25,8 @@
             android:title="@string/incognito_tab"
             android:icon="@drawable/ic_menu_incognito" />
         <item android:id="@+id/find_menu_id"
-            android:title="@string/find_dot"
-            android:icon="@drawable/ic_menu_find"
+            android:title="@*android:string/find_on_page"
+            android:icon="@*android:drawable/ic_menu_find"
             android:alphabeticShortcut="f" />
         <item android:id="@+id/share_page_menu_id"
             android:title="@string/share_page"
diff --git a/res/menu/browser.xml b/res/menu/browser.xml
index adb1bad..2c237a6 100644
--- a/res/menu/browser.xml
+++ b/res/menu/browser.xml
@@ -40,8 +40,8 @@
             android:icon="@drawable/ic_menu_add_bookmark"
             android:alphabeticShortcut="a" />
         <item android:id="@+id/find_menu_id"
-            android:title="@string/find_dot"
-            android:icon="@drawable/ic_menu_find"
+            android:title="@*android:string/find_on_page"
+            android:icon="@*android:drawable/ic_menu_find"
             android:alphabeticShortcut="f" />
         <item android:id="@+id/share_page_menu_id"
             android:title="@string/share_page"
diff --git a/res/menu/copy.xml b/res/menu/copy.xml
deleted file mode 100644
index 018be25..0000000
--- a/res/menu/copy.xml
+++ /dev/null
@@ -1,35 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2010 The Android Open Source Project
-
-     Licensed under the Apache License, Version 2.0 (the "License");
-     you may not use this file except in compliance with the License.
-     You may obtain a copy of the License at
-
-          http://www.apache.org/licenses/LICENSE-2.0
-
-     Unless required by applicable law or agreed to in writing, software
-     distributed under the License is distributed on an "AS IS" BASIS,
-     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-     See the License for the specific language governing permissions and
-     limitations under the License.
--->
-
-<menu xmlns:android="http://schemas.android.com/apk/res/android">
-    <item android:id="@+id/copy"
-        android:icon="@drawable/ic_btn_copy"
-        android:showAsAction="always"
-        />
-    <item android:id="@+id/share"
-        android:icon="@drawable/ic_btn_share"
-        android:showAsAction="always"
-        />
-    <item android:id="@+id/select_all"
-        android:icon="@drawable/ic_btn_select_all"
-        android:showAsAction="always"
-        />
-    <item android:id="@+id/find"
-        android:icon="@drawable/ic_btn_find"
-        android:showAsAction="always"
-        />
-</menu>
-
diff --git a/res/menu/find.xml b/res/menu/find.xml
deleted file mode 100644
index 74a40aa..0000000
--- a/res/menu/find.xml
+++ /dev/null
@@ -1,26 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2010 The Android Open Source Project
-
-     Licensed under the Apache License, Version 2.0 (the "License");
-     you may not use this file except in compliance with the License.
-     You may obtain a copy of the License at
-
-          http://www.apache.org/licenses/LICENSE-2.0
-
-     Unless required by applicable law or agreed to in writing, software
-     distributed under the License is distributed on an "AS IS" BASIS,
-     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-     See the License for the specific language governing permissions and
-     limitations under the License.
--->
-
-<menu xmlns:android="http://schemas.android.com/apk/res/android">
-    <item android:id="@+id/find_prev"
-        android:icon="@drawable/ic_btn_find_prev"
-        android:showAsAction="always"
-        />
-    <item android:id="@+id/find_next"
-        android:icon="@drawable/ic_btn_find_next"
-        android:showAsAction="always"
-        />
-</menu>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 9f1f109..e9c5bec 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -46,25 +46,11 @@
     <string name="action">Sign in</string>
     <!-- The name of the bookmarks and history search suggestion source.  -->
     <string name="bookmarks_search">Browser</string>
-    <!-- Title for text selection contextual mode, displayed in the contextual action bar [CHAR LIMIT=NONE]-->
-    <string name="text_selection_title">Text selection</string>
     <!-- Label for a cancel button.  It is used for multiple cancel buttons in different contexts -->
     <string name="cancel">Cancel</string>
     <!-- Label for a confirm button.  Used in multiple contexts. -->
     <string name="ok">OK</string>
 
-    <!-- Displayed on the Find dialog when there are no matches -->
-    <string name="no_matches">No matches</string>
-
-    <!-- Displayed on the Find dialog to display the index of the highlighted
-         match and total number of matches found in the current page. -->
-    <plurals name="matches_found">
-        <!-- Case of one match -->
-        <item quantity="one">1 match</item>
-        <!-- Case of multiple total matches -->
-        <item quantity="other"><xliff:g id="index" example="2">%d</xliff:g> of <xliff:g id="total" example="137">%d</xliff:g></item>
-    </plurals>
-
     <!-- Displayed on the title bar while the page is loading -->
     <string name="title_bar_loading">Loading\u2026</string>
 
@@ -199,9 +185,6 @@
     <string name="goto_dot">Go</string>
     <!-- Menu item that opens up a new incognito tab.  -->
     <string name="incognito_tab">Open new incognito tab</string>
-    <!-- Menu item that opens up a dialog which allows the user to provide a
-            string and search for it on the page. -->
-    <string name="find_dot">Find on page</string>
     <!-- Menu item to switch to text selection mode for copy and paste. -->
     <string name="select_dot">Select text</string>
     <!-- Title of current windows screen; appears in title bar -->
diff --git a/src/com/android/browser/BrowserActivity.java b/src/com/android/browser/BrowserActivity.java
index 7db2a8d..b62862b 100644
--- a/src/com/android/browser/BrowserActivity.java
+++ b/src/com/android/browser/BrowserActivity.java
@@ -1281,28 +1281,10 @@
 
     @Override
     public ActionMode onStartActionMode(ActionMode.Callback callback) {
-        ActionMode mode = super.onStartActionMode(callback);
-        if (callback instanceof FindActionModeCallback
-                || callback instanceof SelectActionModeCallback) {
-            // For find and select, hide extra title bars.  They will
-            // be replaced in onEndActionMode.
-            Tab tab = mTabControl.getCurrentTab();
-            if (tab.getSubWebView() == null) {
-                // If the find or select is being performed on the main webview,
-                // remove the embedded title bar.
-                WebView mainView = tab.getWebView();
-                if (mainView != null) {
-                    mainView.setEmbeddedTitleBar(null);
-                }
-            }
-            hideFakeTitleBar();
-            mActionMode = mode;
-        } else {
-            // Do not store other ActionModes, since we are unable to determine
-            // when they finish.
-            mActionMode = null;
-        }
-        return mode;
+        mActionMode = super.onStartActionMode(callback);
+        hideFakeTitleBar();
+        // Would like to change the MENU, but onEndActionMode may not be called
+        return mActionMode;
     }
 
     @Override
@@ -1403,7 +1385,7 @@
                 break;
 
             case R.id.find_menu_id:
-                showFindDialog(null);
+                getTopWindow().showFindDialog(null);
                 break;
 
             case R.id.save_webarchive_menu_id:
@@ -1519,11 +1501,13 @@
     }
 
     /*
-     * End the current ActionMode.  Only works for find and select.
+     * End the current ActionMode.
      */
     void endActionMode() {
         if (mActionMode != null) {
-            mActionMode.finish();
+            ActionMode mode = mActionMode;
+            onEndActionMode();
+            mode.finish();
         }
     }
 
@@ -1533,59 +1517,21 @@
      */
     public void onEndActionMode() {
         if (!isInCustomActionMode()) return;
-        // If the Find was being performed in the main WebView, replace the
-        // embedded title bar.
-        Tab currentTab = mTabControl.getCurrentTab();
-        if (currentTab.getSubWebView() == null) {
-            WebView mainView = currentTab.getWebView();
-            if (mainView != null) {
-                mainView.setEmbeddedTitleBar(mTitleBar);
-            }
-        }
         if (mInLoad) {
             // The title bar was hidden, because otherwise it would cover up the
             // find or select dialog. Now that the dialog has been removed,
             // show the fake title bar once again.
             showFakeTitleBar();
         }
+        // Would like to return the menu state to normal, but this does not
+        // necessarily get called.
         mActionMode = null;
     }
 
-    private FindActionModeCallback mFindCallback;
-    private SelectActionModeCallback mSelectCallback;
-
     // For select and find, we keep track of the ActionMode so that
     // finish() can be called as desired.
     private ActionMode mActionMode;
 
-    /*
-     * Open the find ActionMode.
-     * @param text If non null, will be placed in find to be searched for.
-     */
-    public void showFindDialog(String text) {
-        if (null == mFindCallback) {
-            mFindCallback = new FindActionModeCallback(this);
-        }
-        WebView webView = getTopWindow();
-        webView.setFindIsUp(true);
-        mFindCallback.setWebView(webView);
-        startActionMode(mFindCallback);
-        if (text != null) mFindCallback.setText(text);
-    }
-
-    /*
-     * Show the select ActionMode.
-     */
-    public void showSelectDialog() {
-        if (null == mSelectCallback) {
-            mSelectCallback = new SelectActionModeCallback(this);
-        }
-        WebView webView = getTopWindow();
-        webView.setUpSelect();
-        mSelectCallback.setWebView(webView);
-        startActionMode(mSelectCallback);
-    }
-
     @Override
     public boolean onPrepareOptionsMenu(Menu menu) {
         // This happens when the user begins to hold down the menu key, so
diff --git a/src/com/android/browser/FindActionModeCallback.java b/src/com/android/browser/FindActionModeCallback.java
deleted file mode 100644
index 0b0fdae..0000000
--- a/src/com/android/browser/FindActionModeCallback.java
+++ /dev/null
@@ -1,219 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.browser;
-
-import android.content.Context;
-import android.content.res.Resources;
-import android.text.Editable;
-import android.text.Selection;
-import android.text.Spannable;
-import android.text.TextWatcher;
-import android.webkit.WebView;
-import android.widget.EditText;
-import android.widget.TextView;
-import android.view.ActionMode;
-import android.view.LayoutInflater;
-import android.view.Menu;
-import android.view.MenuInflater;
-import android.view.MenuItem;
-import android.view.View;
-import android.view.inputmethod.InputMethodManager;
-
-class FindActionModeCallback implements ActionMode.Callback, TextWatcher,
-        View.OnLongClickListener {
-    private View mCustomView;
-    private EditText mEditText;
-    private TextView mMatches;
-    private WebView mWebView;
-    private InputMethodManager mInput;
-    private Resources mResources;
-    private boolean mMatchesFound;
-    private int mNumberOfMatches;
-    private BrowserActivity mBrowserActivity;
-
-    FindActionModeCallback(BrowserActivity context) {
-        mCustomView = LayoutInflater.from(context).inflate(
-                R.layout.browser_find, null);
-        mEditText = (EditText) mCustomView.findViewById(R.id.edit);
-        // Override long click so that select ActionMode is not opened, which
-        // would exit find ActionMode.
-        mEditText.setOnLongClickListener(this);
-        Spannable span = (Spannable) mEditText.getText();
-        int length = span.length();
-        span.setSpan(this, 0, length, Spannable.SPAN_INCLUSIVE_INCLUSIVE);
-        mMatches = (TextView) mCustomView.findViewById(R.id.matches);
-        mInput = (InputMethodManager)
-                context.getSystemService(Context.INPUT_METHOD_SERVICE);
-        mResources = context.getResources();
-        mBrowserActivity = context;
-    }
-
-    /*
-     * Place text in the text field so it can be searched for.  Need to press
-     * the find next or find previous button to find all of the matches.
-     */
-    void setText(String text) {
-        mEditText.setText(text);
-        Spannable span = (Spannable) mEditText.getText();
-        int length = span.length();
-        // Ideally, we would like to set the selection to the whole field,
-        // but this brings up the Text selection CAB, which dismisses this
-        // one.
-        Selection.setSelection(span, length, length);
-        // Necessary each time we set the text, so that this will watch
-        // changes to it.
-        span.setSpan(this, 0, length, Spannable.SPAN_INCLUSIVE_INCLUSIVE);
-        mMatchesFound = false;
-    }
-
-    /*
-     * Set the WebView to search.  Must be non null, and set before calling
-     * startActionMode.
-     */
-    void setWebView(WebView webView) {
-        if (null == webView) {
-            throw new AssertionError("WebView supplied to "
-                    + "FindActionModeCallback cannot be null");
-        }
-        mWebView = webView;
-    }
-
-    /*
-     * Move the highlight to the next match.
-     * @param next If true, find the next match further down in the document.
-     *             If false, find the previous match, up in the document.
-     */
-    private void findNext(boolean next) {
-        if (mWebView == null) {
-            throw new AssertionError(
-                    "No WebView for FindActionModeCallback::findNext");
-        }
-        mWebView.findNext(next);
-    }
-
-    /*
-     * Highlight all the instances of the string from mEditText in mWebView.
-     */
-    private void findAll() {
-        if (mWebView == null) {
-            throw new AssertionError(
-                    "No WebView for FindActionModeCallback::findAll");
-        }
-        CharSequence find = mEditText.getText();
-        if (0 == find.length()) {
-            mWebView.clearMatches();
-            mMatches.setVisibility(View.INVISIBLE);
-            mMatchesFound = false;
-        } else {
-            mMatchesFound = true;
-            mMatches.setVisibility(View.VISIBLE);
-            mNumberOfMatches = mWebView.findAll(find.toString());
-            if (0 == mNumberOfMatches) {
-                mMatches.setText(mResources.getString(R.string.no_matches));
-            } else {
-                updateMatchesString();
-            }
-        }
-    }
-
-    /*
-     * Update the string which tells the user how many matches were found, and
-     * which match is currently highlighted.
-     */
-    private void updateMatchesString() {
-        String template = mResources.getQuantityString(R.plurals.matches_found,
-                mNumberOfMatches, mWebView.findIndex() + 1, mNumberOfMatches);
-
-        mMatches.setText(template);
-    }
-
-    // OnLongClickListener implementation
-
-    @Override
-    public boolean onLongClick(View v) { return true; }
-
-    // ActionMode.Callback implementation
-
-    @Override
-    public boolean onCreateActionMode(ActionMode mode, Menu menu) {
-        mode.setCustomView(mCustomView);
-        mode.getMenuInflater().inflate(R.menu.find, menu);
-        // Ideally, we would like to preserve the old find text, but it
-        // brings up the Text selection CAB, and therefore dismisses
-        // find
-        setText("");
-        mMatches.setVisibility(View.INVISIBLE);
-        mMatchesFound = false;
-        mMatches.setText("0");
-        mEditText.requestFocus();
-        mInput.showSoftInput(mEditText, 0);
-        return true;
-    }
-
-    @Override
-    public void onDestroyActionMode(ActionMode mode) {
-        mBrowserActivity.onEndActionMode();
-        mWebView.notifyFindDialogDismissed();
-        mInput.hideSoftInputFromWindow(mWebView.getWindowToken(), 0);
-    }
-
-    @Override
-    public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
-        return false;
-    }
-
-    @Override
-    public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
-        if (!mMatchesFound) {
-            findAll();
-            return true;
-        }
-        switch(item.getItemId()) {
-            case R.id.find_prev:
-                findNext(false);
-                break;
-            case R.id.find_next:
-                findNext(true);
-                break;
-            default:
-                return false;
-        }
-        updateMatchesString();
-        return true;
-    }
-
-    // TextWatcher methods
-
-    @Override
-    public void beforeTextChanged(CharSequence s,
-                                  int start,
-                                  int count,
-                                  int after) {
-    }
-
-    @Override
-    public void onTextChanged(CharSequence s,
-                              int start,
-                              int before,
-                              int count) {
-        findAll();
-    }
-
-    @Override
-    public void afterTextChanged(Editable s) { }
-
-}
diff --git a/src/com/android/browser/SelectActionModeCallback.java b/src/com/android/browser/SelectActionModeCallback.java
deleted file mode 100644
index 4c2554f..0000000
--- a/src/com/android/browser/SelectActionModeCallback.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.browser;
-
-import android.provider.Browser;
-import android.webkit.WebView;
-import android.view.ActionMode;
-import android.view.Menu;
-import android.view.MenuItem;
-
-class SelectActionModeCallback implements ActionMode.Callback {
-    private WebView mWebView;
-    private BrowserActivity mBrowserActivity;
-
-    SelectActionModeCallback(BrowserActivity context) {
-        mBrowserActivity = context;
-    }
-
-    /*
-     * Set the WebView to be copied from.
-     */
-    void setWebView(WebView webView) {
-        mWebView = webView;
-    }
-
-    // ActionMode.Callback implementation
-
-    @Override
-    public boolean onCreateActionMode(ActionMode mode, Menu menu) {
-        mode.getMenuInflater().inflate(R.menu.copy, menu);
-        mode.setTitle(R.string.text_selection_title);
-        return true;
-    }
-
-    @Override
-    public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
-        return true;
-    }
-
-    @Override
-    public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
-        switch(item.getItemId()) {
-            case R.id.copy:
-                mWebView.copySelection();
-                mode.finish();
-                break;
-
-            case R.id.share:
-                String selection = mWebView.getSelection();
-                Browser.sendString(mBrowserActivity, selection);
-                mode.finish();
-                break;
-
-            case R.id.select_all:
-                mWebView.selectAll();
-                break;
-
-            case R.id.find:
-                String sel= mWebView.getSelection();
-                mode.finish();
-                mBrowserActivity.showFindDialog(sel);
-                break;
-
-            default:
-                return false;
-        }
-        return true;
-    }
-
-    @Override
-    public void onDestroyActionMode(ActionMode mode) {
-        mBrowserActivity.onEndActionMode();
-        mWebView.notifySelectDialogDismissed();
-    }
-}
diff --git a/src/com/android/browser/Tab.java b/src/com/android/browser/Tab.java
index e7309a6..a9ab058 100644
--- a/src/com/android/browser/Tab.java
+++ b/src/com/android/browser/Tab.java
@@ -1045,16 +1045,6 @@
         }
 
         @Override
-        public void onSelectionDone(WebView view) {
-            if (mInForeground) mActivity.endActionMode();
-        }
-
-        @Override
-        public void onSelectionStart(WebView view) {
-            if (mInForeground) mActivity.showSelectDialog();
-        }
-
-        @Override
         public void onShowCustomView(View view,
                 WebChromeClient.CustomViewCallback callback) {
             if (mInForeground) mActivity.onShowCustomView(view, callback);