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();
|
Tab tab = Tabs.getInstance().getSelectedTab();
|
||||||
// Setting a null title for about:home will ensure we just see
|
// Setting a null title for about:home will ensure we just see
|
||||||
// the "Enter Search or Address" placeholder text
|
// 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;
|
title = null;
|
||||||
mAwesomeBar.setText(title);
|
mAwesomeBar.setText(title);
|
||||||
}
|
}
|
||||||
@ -339,11 +339,12 @@ public class BrowserToolbar extends LinearLayout {
|
|||||||
public void refresh() {
|
public void refresh() {
|
||||||
Tab tab = Tabs.getInstance().getSelectedTab();
|
Tab tab = Tabs.getInstance().getSelectedTab();
|
||||||
if (tab != null) {
|
if (tab != null) {
|
||||||
|
String url = tab.getURL();
|
||||||
setTitle(tab.getDisplayTitle());
|
setTitle(tab.getDisplayTitle());
|
||||||
setFavicon(tab.getFavicon());
|
setFavicon(tab.getFavicon());
|
||||||
setSecurityMode(tab.getSecurityMode());
|
setSecurityMode(tab.getSecurityMode());
|
||||||
setProgressVisibility(tab.isLoading());
|
setProgressVisibility(tab.isLoading());
|
||||||
setShadowVisibility(!(tab.getURL().startsWith("about:")));
|
setShadowVisibility((url == null) || !url.startsWith("about:"));
|
||||||
updateTabCount(Tabs.getInstance().getCount());
|
updateTabCount(Tabs.getInstance().getCount());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -432,7 +432,7 @@ abstract public class GeckoApp
|
|||||||
MenuItem saveAsPDF = aMenu.findItem(R.id.save_as_pdf);
|
MenuItem saveAsPDF = aMenu.findItem(R.id.save_as_pdf);
|
||||||
MenuItem charEncoding = aMenu.findItem(R.id.char_encoding);
|
MenuItem charEncoding = aMenu.findItem(R.id.char_encoding);
|
||||||
|
|
||||||
if (tab == null) {
|
if (tab == null || tab.getURL() == null) {
|
||||||
bookmark.setEnabled(false);
|
bookmark.setEnabled(false);
|
||||||
forward.setEnabled(false);
|
forward.setEnabled(false);
|
||||||
share.setEnabled(false);
|
share.setEnabled(false);
|
||||||
@ -455,9 +455,8 @@ abstract public class GeckoApp
|
|||||||
|
|
||||||
// Disable share menuitem for about:, chrome: and file: URIs
|
// Disable share menuitem for about:, chrome: and file: URIs
|
||||||
String scheme = Uri.parse(tab.getURL()).getScheme();
|
String scheme = Uri.parse(tab.getURL()).getScheme();
|
||||||
boolean enabled = scheme != null && !(scheme.equals("about") || scheme.equals("chrome") ||
|
share.setEnabled(!(scheme.equals("about") || scheme.equals("chrome") ||
|
||||||
scheme.equals("file"));
|
scheme.equals("file")));
|
||||||
share.setEnabled(enabled);
|
|
||||||
|
|
||||||
// Disable save as PDF for about:home and xul pages
|
// Disable save as PDF for about:home and xul pages
|
||||||
saveAsPDF.setEnabled(!(tab.getURL().equals("about:home") ||
|
saveAsPDF.setEnabled(!(tab.getURL().equals("about:home") ||
|
||||||
@ -500,8 +499,12 @@ abstract public class GeckoApp
|
|||||||
case R.id.share:
|
case R.id.share:
|
||||||
tab = Tabs.getInstance().getSelectedTab();
|
tab = Tabs.getInstance().getSelectedTab();
|
||||||
if (tab != null) {
|
if (tab != null) {
|
||||||
GeckoAppShell.openUriExternal(tab.getURL(), "text/plain", "", "",
|
String url = tab.getURL();
|
||||||
Intent.ACTION_SEND, tab.getTitle());
|
if (url == null)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
GeckoAppShell.openUriExternal(url, "text/plain", "", "",
|
||||||
|
Intent.ACTION_SEND, tab.getTitle());
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
case R.id.reload:
|
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) {
|
public Tab(int id, String url, boolean external, int parentId, String title) {
|
||||||
mId = id;
|
mId = id;
|
||||||
mUrl = url;
|
mUrl = url;
|
||||||
@ -148,6 +144,7 @@ public final class Tab {
|
|||||||
return mParentId;
|
return mParentId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// may be null if user-entered query hasn't yet been resolved to a URI
|
||||||
public String getURL() {
|
public String getURL() {
|
||||||
return mUrl;
|
return mUrl;
|
||||||
}
|
}
|
||||||
@ -370,7 +367,11 @@ public final class Tab {
|
|||||||
if (mCheckBookmarkTask != null)
|
if (mCheckBookmarkTask != null)
|
||||||
mCheckBookmarkTask.cancel(false);
|
mCheckBookmarkTask.cancel(false);
|
||||||
|
|
||||||
mCheckBookmarkTask = new CheckBookmarkTask(getURL());
|
String url = getURL();
|
||||||
|
if (url == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
mCheckBookmarkTask = new CheckBookmarkTask(url);
|
||||||
mCheckBookmarkTask.execute();
|
mCheckBookmarkTask.execute();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -379,7 +380,11 @@ public final class Tab {
|
|||||||
public void addBookmark() {
|
public void addBookmark() {
|
||||||
GeckoAppShell.getHandler().post(new Runnable() {
|
GeckoAppShell.getHandler().post(new Runnable() {
|
||||||
public void run() {
|
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() {
|
public void removeBookmark() {
|
||||||
GeckoAppShell.getHandler().post(new Runnable() {
|
GeckoAppShell.getHandler().post(new Runnable() {
|
||||||
public void run() {
|
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) {
|
private void saveThumbnailToDB(BitmapDrawable thumbnail) {
|
||||||
try {
|
try {
|
||||||
BrowserDB.updateThumbnailForUrl(mContentResolver, getURL(), thumbnail);
|
String url = getURL();
|
||||||
|
if (url == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
BrowserDB.updateThumbnailForUrl(mContentResolver, url, thumbnail);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// ignore
|
// ignore
|
||||||
}
|
}
|
||||||
|
@ -81,7 +81,8 @@ public class Tabs implements GeckoEventListener {
|
|||||||
if (tabs.containsKey(id))
|
if (tabs.containsKey(id))
|
||||||
return tabs.get(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");
|
Boolean external = params.getBoolean("external");
|
||||||
int parentId = params.getInt("parentId");
|
int parentId = params.getInt("parentId");
|
||||||
String title = params.getString("title");
|
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;
|
return tab;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -121,7 +122,7 @@ public class Tabs implements GeckoEventListener {
|
|||||||
if (tab == null)
|
if (tab == null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
if (tab.getURL().equals("about:home"))
|
if ("about:home".equals(tab.getURL()))
|
||||||
GeckoApp.mAppContext.showAboutHome();
|
GeckoApp.mAppContext.showAboutHome();
|
||||||
else
|
else
|
||||||
GeckoApp.mAppContext.hideAboutHome();
|
GeckoApp.mAppContext.hideAboutHome();
|
||||||
@ -131,12 +132,13 @@ public class Tabs implements GeckoEventListener {
|
|||||||
GeckoApp.mAutoCompletePopup.hide();
|
GeckoApp.mAutoCompletePopup.hide();
|
||||||
// Do we need to do this check?
|
// Do we need to do this check?
|
||||||
if (isSelectedTab(tab)) {
|
if (isSelectedTab(tab)) {
|
||||||
|
String url = tab.getURL();
|
||||||
GeckoApp.mBrowserToolbar.setTitle(tab.getDisplayTitle());
|
GeckoApp.mBrowserToolbar.setTitle(tab.getDisplayTitle());
|
||||||
GeckoApp.mBrowserToolbar.setFavicon(tab.getFavicon());
|
GeckoApp.mBrowserToolbar.setFavicon(tab.getFavicon());
|
||||||
GeckoApp.mBrowserToolbar.setSecurityMode(tab.getSecurityMode());
|
GeckoApp.mBrowserToolbar.setSecurityMode(tab.getSecurityMode());
|
||||||
GeckoApp.mBrowserToolbar.setProgressVisibility(tab.isLoading());
|
GeckoApp.mBrowserToolbar.setProgressVisibility(tab.isLoading());
|
||||||
GeckoApp.mDoorHangerPopup.updatePopup();
|
GeckoApp.mDoorHangerPopup.updatePopup();
|
||||||
GeckoApp.mBrowserToolbar.setShadowVisibility(!(tab.getURL().startsWith("about:")));
|
GeckoApp.mBrowserToolbar.setShadowVisibility((url == null) || !url.startsWith("about:"));
|
||||||
notifyListeners(tab, TabEvents.SELECTED);
|
notifyListeners(tab, TabEvents.SELECTED);
|
||||||
|
|
||||||
if (oldTab != null)
|
if (oldTab != null)
|
||||||
|
@ -1528,17 +1528,23 @@ Tab.prototype = {
|
|||||||
let frameLoader = this.browser.QueryInterface(Ci.nsIFrameLoaderOwner).frameLoader;
|
let frameLoader = this.browser.QueryInterface(Ci.nsIFrameLoaderOwner).frameLoader;
|
||||||
frameLoader.clipSubdocument = false;
|
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;
|
this.id = ++gTabIDFactory;
|
||||||
|
|
||||||
let message = {
|
let message = {
|
||||||
gecko: {
|
gecko: {
|
||||||
type: "Tab:Added",
|
type: "Tab:Added",
|
||||||
tabID: this.id,
|
tabID: this.id,
|
||||||
uri: aURL,
|
uri: uri,
|
||||||
parentId: ("parentId" in aParams) ? aParams.parentId : -1,
|
parentId: ("parentId" in aParams) ? aParams.parentId : -1,
|
||||||
external: ("external" in aParams) ? aParams.external : false,
|
external: ("external" in aParams) ? aParams.external : false,
|
||||||
selected: ("selected" in aParams) ? aParams.selected : true,
|
selected: ("selected" in aParams) ? aParams.selected : true,
|
||||||
title: aParams.title || "",
|
title: aParams.title || aURL,
|
||||||
delayLoad: aParams.delayLoad || false
|
delayLoad: aParams.delayLoad || false
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user