mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-18 04:44:17 +00:00
Bug 1347616 - Fall back to bookmark when manifest invalid. r=sebastian
This commit is contained in:
parent
914dd4b76c
commit
f36bbc62c5
@ -764,6 +764,7 @@ public class BrowserApp extends GeckoApp
|
||||
"Telemetry:Gather",
|
||||
"Download:AndroidDownloadManager",
|
||||
"Website:AppInstalled",
|
||||
"Website:AppInstallFailed",
|
||||
"Website:Metadata",
|
||||
null);
|
||||
|
||||
@ -1519,6 +1520,7 @@ public class BrowserApp extends GeckoApp
|
||||
"Telemetry:Gather",
|
||||
"Download:AndroidDownloadManager",
|
||||
"Website:AppInstalled",
|
||||
"Website:AppInstallFailed",
|
||||
"Website:Metadata",
|
||||
null);
|
||||
|
||||
@ -2041,6 +2043,12 @@ public class BrowserApp extends GeckoApp
|
||||
createAppShortcut(name, startUrl, manifestPath, icon);
|
||||
break;
|
||||
|
||||
case "Website:AppInstallFailed":
|
||||
final String title = message.getString("title");
|
||||
final String bookmarkUrl = message.getString("url");
|
||||
createBrowserShortcut(title, bookmarkUrl);
|
||||
break;
|
||||
|
||||
case "Updater:Launch":
|
||||
/**
|
||||
* Launch UI that lets the user update Firefox.
|
||||
|
@ -2016,23 +2016,28 @@ public abstract class GeckoApp
|
||||
final GeckoBundle message = new GeckoBundle();
|
||||
message.putInt("iconSize", GeckoAppShell.getPreferredIconSize());
|
||||
message.putString("manifestUrl", manifestUrl);
|
||||
message.putString("originalUrl", url);
|
||||
message.putString("originalTitle", title);
|
||||
EventDispatcher.getInstance().dispatch("Browser:LoadManifest", message);
|
||||
return;
|
||||
}
|
||||
|
||||
// Otherwise we try to pick best icon from favicons etc
|
||||
Icons.with(this)
|
||||
.pageUrl(url)
|
||||
.skipNetwork()
|
||||
.skipMemory()
|
||||
.forLauncherIcon()
|
||||
.build()
|
||||
.execute(new IconCallback() {
|
||||
@Override
|
||||
public void onIconResponse(IconResponse response) {
|
||||
createShortcut(title, url, response.getBitmap());
|
||||
}
|
||||
});
|
||||
createBrowserShortcut(title, url);
|
||||
}
|
||||
|
||||
public void createBrowserShortcut(final String title, final String url) {
|
||||
Icons.with(this)
|
||||
.pageUrl(url)
|
||||
.skipNetwork()
|
||||
.skipMemory()
|
||||
.forLauncherIcon()
|
||||
.build()
|
||||
.execute(new IconCallback() {
|
||||
@Override
|
||||
public void onIconResponse(IconResponse response) {
|
||||
createShortcut(title, url, response.getBitmap());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void createShortcut(final String aTitle, final String aURI, final Bitmap aIcon) {
|
||||
|
@ -1676,7 +1676,7 @@ var BrowserApp = {
|
||||
|
||||
switch (event) {
|
||||
case "Browser:LoadManifest": {
|
||||
installManifest(browser, data.manifestUrl, data.iconSize);
|
||||
installManifest(browser, data);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -2206,11 +2206,11 @@ var BrowserApp = {
|
||||
},
|
||||
};
|
||||
|
||||
async function installManifest(browser, manifestUrl, iconSize) {
|
||||
async function installManifest(browser, data) {
|
||||
try {
|
||||
const manifest = await Manifests.getManifest(browser, manifestUrl);
|
||||
const manifest = await Manifests.getManifest(browser, data.manifestUrl);
|
||||
await manifest.install();
|
||||
const icon = await manifest.icon(iconSize);
|
||||
const icon = await manifest.icon(data.iconSize);
|
||||
GlobalEventDispatcher.sendRequest({
|
||||
type: "Website:AppInstalled",
|
||||
icon,
|
||||
@ -2220,6 +2220,12 @@ async function installManifest(browser, manifestUrl, iconSize) {
|
||||
});
|
||||
} catch (err) {
|
||||
Cu.reportError("Failed to install: " + err.message);
|
||||
// If we fail to install via the manifest, we will fall back to a standard bookmark
|
||||
GlobalEventDispatcher.sendRequest({
|
||||
type: "Website:AppInstallFailed",
|
||||
url: data.originalUrl,
|
||||
title: data.originalTitle
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user