mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-16 14:55:47 +00:00
Bug 726080 - Only update tab URLs if valid. r=mfinkle
This commit is contained in:
parent
8000bc23b3
commit
e9375d5144
@ -294,7 +294,7 @@ public class BrowserToolbar extends LinearLayout {
|
||||
Tab tab = Tabs.getInstance().getSelectedTab();
|
||||
// Setting a null title for about:home will ensure we just see
|
||||
// the "Enter Search or Address" placeholder text
|
||||
if (tab != null && tab.getURL().equals("about:home"))
|
||||
if (tab != null && "about:home".equals(tab.getURL()))
|
||||
title = null;
|
||||
mAwesomeBar.setText(title);
|
||||
}
|
||||
@ -339,11 +339,12 @@ public class BrowserToolbar extends LinearLayout {
|
||||
public void refresh() {
|
||||
Tab tab = Tabs.getInstance().getSelectedTab();
|
||||
if (tab != null) {
|
||||
String url = tab.getURL();
|
||||
setTitle(tab.getDisplayTitle());
|
||||
setFavicon(tab.getFavicon());
|
||||
setSecurityMode(tab.getSecurityMode());
|
||||
setProgressVisibility(tab.isLoading());
|
||||
setShadowVisibility(!(tab.getURL().startsWith("about:")));
|
||||
setShadowVisibility((url == null) || !url.startsWith("about:"));
|
||||
updateTabCount(Tabs.getInstance().getCount());
|
||||
}
|
||||
}
|
||||
|
@ -432,7 +432,7 @@ abstract public class GeckoApp
|
||||
MenuItem saveAsPDF = aMenu.findItem(R.id.save_as_pdf);
|
||||
MenuItem charEncoding = aMenu.findItem(R.id.char_encoding);
|
||||
|
||||
if (tab == null) {
|
||||
if (tab == null || tab.getURL() == null) {
|
||||
bookmark.setEnabled(false);
|
||||
forward.setEnabled(false);
|
||||
share.setEnabled(false);
|
||||
@ -455,9 +455,8 @@ abstract public class GeckoApp
|
||||
|
||||
// Disable share menuitem for about:, chrome: and file: URIs
|
||||
String scheme = Uri.parse(tab.getURL()).getScheme();
|
||||
boolean enabled = scheme != null && !(scheme.equals("about") || scheme.equals("chrome") ||
|
||||
scheme.equals("file"));
|
||||
share.setEnabled(enabled);
|
||||
share.setEnabled(!(scheme.equals("about") || scheme.equals("chrome") ||
|
||||
scheme.equals("file")));
|
||||
|
||||
// Disable save as PDF for about:home and xul pages
|
||||
saveAsPDF.setEnabled(!(tab.getURL().equals("about:home") ||
|
||||
@ -500,8 +499,12 @@ abstract public class GeckoApp
|
||||
case R.id.share:
|
||||
tab = Tabs.getInstance().getSelectedTab();
|
||||
if (tab != null) {
|
||||
GeckoAppShell.openUriExternal(tab.getURL(), "text/plain", "", "",
|
||||
Intent.ACTION_SEND, tab.getTitle());
|
||||
String url = tab.getURL();
|
||||
if (url == null)
|
||||
return false;
|
||||
|
||||
GeckoAppShell.openUriExternal(url, "text/plain", "", "",
|
||||
Intent.ACTION_SEND, tab.getTitle());
|
||||
}
|
||||
return true;
|
||||
case R.id.reload:
|
||||
|
@ -102,10 +102,6 @@ public final class Tab {
|
||||
}
|
||||
}
|
||||
|
||||
public Tab() {
|
||||
this(-1, "", false, -1, "");
|
||||
}
|
||||
|
||||
public Tab(int id, String url, boolean external, int parentId, String title) {
|
||||
mId = id;
|
||||
mUrl = url;
|
||||
@ -148,6 +144,7 @@ public final class Tab {
|
||||
return mParentId;
|
||||
}
|
||||
|
||||
// may be null if user-entered query hasn't yet been resolved to a URI
|
||||
public String getURL() {
|
||||
return mUrl;
|
||||
}
|
||||
@ -370,7 +367,11 @@ public final class Tab {
|
||||
if (mCheckBookmarkTask != null)
|
||||
mCheckBookmarkTask.cancel(false);
|
||||
|
||||
mCheckBookmarkTask = new CheckBookmarkTask(getURL());
|
||||
String url = getURL();
|
||||
if (url == null)
|
||||
return;
|
||||
|
||||
mCheckBookmarkTask = new CheckBookmarkTask(url);
|
||||
mCheckBookmarkTask.execute();
|
||||
}
|
||||
});
|
||||
@ -379,7 +380,11 @@ public final class Tab {
|
||||
public void addBookmark() {
|
||||
GeckoAppShell.getHandler().post(new Runnable() {
|
||||
public void run() {
|
||||
BrowserDB.addBookmark(mContentResolver, getTitle(), getURL());
|
||||
String url = getURL();
|
||||
if (url == null)
|
||||
return;
|
||||
|
||||
BrowserDB.addBookmark(mContentResolver, getTitle(), url);
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -387,7 +392,11 @@ public final class Tab {
|
||||
public void removeBookmark() {
|
||||
GeckoAppShell.getHandler().post(new Runnable() {
|
||||
public void run() {
|
||||
BrowserDB.removeBookmarksWithURL(mContentResolver, getURL());
|
||||
String url = getURL();
|
||||
if (url == null)
|
||||
return;
|
||||
|
||||
BrowserDB.removeBookmarksWithURL(mContentResolver, url);
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -541,7 +550,11 @@ public final class Tab {
|
||||
|
||||
private void saveThumbnailToDB(BitmapDrawable thumbnail) {
|
||||
try {
|
||||
BrowserDB.updateThumbnailForUrl(mContentResolver, getURL(), thumbnail);
|
||||
String url = getURL();
|
||||
if (url == null)
|
||||
return;
|
||||
|
||||
BrowserDB.updateThumbnailForUrl(mContentResolver, url, thumbnail);
|
||||
} catch (Exception e) {
|
||||
// ignore
|
||||
}
|
||||
|
@ -81,7 +81,8 @@ public class Tabs implements GeckoEventListener {
|
||||
if (tabs.containsKey(id))
|
||||
return tabs.get(id);
|
||||
|
||||
String url = params.getString("uri");
|
||||
// null strings return "null" (http://code.google.com/p/android/issues/detail?id=13830)
|
||||
String url = params.isNull("uri") ? null : params.getString("uri");
|
||||
Boolean external = params.getBoolean("external");
|
||||
int parentId = params.getInt("parentId");
|
||||
String title = params.getString("title");
|
||||
@ -98,7 +99,7 @@ public class Tabs implements GeckoEventListener {
|
||||
});
|
||||
}
|
||||
|
||||
Log.i(LOGTAG, "Added a tab with id: " + id + ", url: " + url);
|
||||
Log.i(LOGTAG, "Added a tab with id: " + id);
|
||||
return tab;
|
||||
}
|
||||
|
||||
@ -121,7 +122,7 @@ public class Tabs implements GeckoEventListener {
|
||||
if (tab == null)
|
||||
return null;
|
||||
|
||||
if (tab.getURL().equals("about:home"))
|
||||
if ("about:home".equals(tab.getURL()))
|
||||
GeckoApp.mAppContext.showAboutHome();
|
||||
else
|
||||
GeckoApp.mAppContext.hideAboutHome();
|
||||
@ -131,12 +132,13 @@ public class Tabs implements GeckoEventListener {
|
||||
GeckoApp.mAutoCompletePopup.hide();
|
||||
// Do we need to do this check?
|
||||
if (isSelectedTab(tab)) {
|
||||
String url = tab.getURL();
|
||||
GeckoApp.mBrowserToolbar.setTitle(tab.getDisplayTitle());
|
||||
GeckoApp.mBrowserToolbar.setFavicon(tab.getFavicon());
|
||||
GeckoApp.mBrowserToolbar.setSecurityMode(tab.getSecurityMode());
|
||||
GeckoApp.mBrowserToolbar.setProgressVisibility(tab.isLoading());
|
||||
GeckoApp.mDoorHangerPopup.updatePopup();
|
||||
GeckoApp.mBrowserToolbar.setShadowVisibility(!(tab.getURL().startsWith("about:")));
|
||||
GeckoApp.mBrowserToolbar.setShadowVisibility((url == null) || !url.startsWith("about:"));
|
||||
notifyListeners(tab, TabEvents.SELECTED);
|
||||
|
||||
if (oldTab != null)
|
||||
|
@ -1528,17 +1528,23 @@ Tab.prototype = {
|
||||
let frameLoader = this.browser.QueryInterface(Ci.nsIFrameLoaderOwner).frameLoader;
|
||||
frameLoader.clipSubdocument = false;
|
||||
|
||||
// only set tab uri if uri is valid
|
||||
let uri = null;
|
||||
try {
|
||||
uri = Services.io.newURI(aURL, null, null).spec;
|
||||
} catch (e) {}
|
||||
|
||||
this.id = ++gTabIDFactory;
|
||||
|
||||
let message = {
|
||||
gecko: {
|
||||
type: "Tab:Added",
|
||||
tabID: this.id,
|
||||
uri: aURL,
|
||||
uri: uri,
|
||||
parentId: ("parentId" in aParams) ? aParams.parentId : -1,
|
||||
external: ("external" in aParams) ? aParams.external : false,
|
||||
selected: ("selected" in aParams) ? aParams.selected : true,
|
||||
title: aParams.title || "",
|
||||
title: aParams.title || aURL,
|
||||
delayLoad: aParams.delayLoad || false
|
||||
}
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user