summaryrefslogtreecommitdiffstats
path: root/src/com/android/browser/HomepageHandler.java
diff options
context:
space:
mode:
authorVivek Sekhar <vsekhar@codeaurora.org>2014-09-12 19:13:23 -0700
committerWebTech Code Review <code-review@localhost>2014-10-28 13:18:00 -0700
commit0e10a20dff43af1c6111b8df606d1a83b51d51d2 (patch)
tree56e8895e53d5c368bc8a79ab436d3224288c95c4 /src/com/android/browser/HomepageHandler.java
parentf73780b2cfe261dad227f0ceab4e1c40f440d92d (diff)
downloadandroid_packages_apps_Gello-0e10a20dff43af1c6111b8df606d1a83b51d51d2.tar.gz
android_packages_apps_Gello-0e10a20dff43af1c6111b8df606d1a83b51d51d2.tar.bz2
android_packages_apps_Gello-0e10a20dff43af1c6111b8df606d1a83b51d51d2.zip
Porting newer changes from 1599-qrd
Fixes NULL pointer exception on crash recovery Browser registers JS interface during crash recovery for each tab. Some of tabs are not recovered (e.g. Incognito tabs). The code was setting the JS interface for these tabs as well, while the tab pointer was NULL. Change-Id: Ic0255d4b98eef694d7b1b0a92595332b88cca695 Add javascript interface for 'def_landing_page'. Fix CR: 731360. Change-Id: I15f5de350cb4dd74198c4ca64f92a2d15f52068b Fixes issue seen on carrier's homepage. - When the user navigates from a carrier's homepage to any bookmark entry and goes back to homepage, the buttons on the homepage was not responsive. The issue was related to how JavascriptInterface was added to webview and required a reload of the page during page navigation. The issue is fixed by not removing the JavascriptInterface that was added to a webview when the user navigates from the carrier's homepage and granting access to the java methods of the addJavascriptInterface only if the URL is the carrier's homepage. Change-Id: Ie328f2c8dbb41869bffdaf840c93d560171e79fb Change-Id: I17f34c19890197714e661638d028fc74bfc38529
Diffstat (limited to 'src/com/android/browser/HomepageHandler.java')
-rw-r--r--src/com/android/browser/HomepageHandler.java94
1 files changed, 94 insertions, 0 deletions
diff --git a/src/com/android/browser/HomepageHandler.java b/src/com/android/browser/HomepageHandler.java
new file mode 100644
index 00000000..f447226a
--- /dev/null
+++ b/src/com/android/browser/HomepageHandler.java
@@ -0,0 +1,94 @@
+/*
+ * Copyright (c) 2014, The Linux Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * * Neither the name of The Linux Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+package com.android.browser;
+
+import com.android.browser.UI.ComboViews;
+
+import android.content.Context;
+import android.os.Handler;
+import android.app.Activity;
+
+import android.webkit.JavascriptInterface;
+
+import org.codeaurora.swe.WebView;
+
+public class HomepageHandler {
+
+ private Activity mActivity;
+ private Controller mController;
+ private Handler mHandler = new Handler();
+
+ HomepageHandler(Activity activity, Controller controller ){
+ mActivity = activity;
+ mController = controller;
+ }
+
+ // add for carrier homepage feature
+ @JavascriptInterface
+ public void loadBookmarks() {
+ Tab t = mController.mTabControl.getCurrentTab();
+ if (isDefaultLandingPage(t.mCurrentState.mUrl)) {
+ mHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ mController.bookmarksOrHistoryPicker(ComboViews.Bookmarks);
+ }
+ });
+ }
+ }
+
+ // add for carrier homepage feature
+ @JavascriptInterface
+ public void loadHistory() {
+ Tab t = mController.mTabControl.getCurrentTab();
+ if (isDefaultLandingPage(t.mCurrentState.mUrl)) {
+ mHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ mController.bookmarksOrHistoryPicker(ComboViews.History);
+ }
+ });
+ }
+ }
+
+ public void registerJsInterface(WebView webview, String url){
+ if (isDefaultLandingPage(url)) {
+ webview.getSettings().setJavaScriptEnabled(true);
+ webview.addJavascriptInterface(this, "default_homepage");
+ }
+ }
+
+ public boolean isDefaultLandingPage(String url) {
+ return (url != null &&
+ url.equals(mActivity.getResources().getString(R.string.def_landing_page)) &&
+ url.startsWith("file:///"));
+ }
+}