From 6c702eed5791d0d46fbe3dfd3054549997f218dc Mon Sep 17 00:00:00 2001 From: John Reck Date: Fri, 7 Jan 2011 09:41:53 -0800 Subject: Fix NPE in queryIsBookmark Bug: 3326838 Fixed a case where a Tab can have a null URL and added null checks to the DataController. Change-Id: I9b27479c522928cde5d427919f2f921ca94aec5d --- src/com/android/browser/DataController.java | 7 ++++++- src/com/android/browser/Tab.java | 3 +++ 2 files changed, 9 insertions(+), 1 deletion(-) (limited to 'src/com/android') diff --git a/src/com/android/browser/DataController.java b/src/com/android/browser/DataController.java index aa233fd..a56fce8 100644 --- a/src/com/android/browser/DataController.java +++ b/src/com/android/browser/DataController.java @@ -100,7 +100,12 @@ public class DataController { } public void queryBookmarkStatus(String url, OnQueryUrlIsBookmark replyTo) { - mDataHandler.sendMessage(QUERY_URL_IS_BOOKMARK, url, replyTo); + if (url == null || url.trim().length() == 0) { + // null or empty url is never a bookmark + replyTo.onQueryUrlIsBookmark(url, false); + return; + } + mDataHandler.sendMessage(QUERY_URL_IS_BOOKMARK, url.trim(), replyTo); } // The standard Handler and Message classes don't allow the queue manipulation diff --git a/src/com/android/browser/Tab.java b/src/com/android/browser/Tab.java index c4edda6..320d3b3 100644 --- a/src/com/android/browser/Tab.java +++ b/src/com/android/browser/Tab.java @@ -546,6 +546,9 @@ class Tab { mInPageLoad = false; // Sync state (in case of stop/timeout) mCurrentState.mUrl = view.getUrl(); + if (mCurrentState.mUrl == null) { + mCurrentState.mUrl = url != null ? url : ""; + } mCurrentState.mTitle = view.getTitle(); mCurrentState.mFavicon = view.getFavicon(); if (!URLUtil.isHttpsUrl(mCurrentState.mUrl)) { -- cgit v1.1