Bug 1078365 - ""Feedback:LastUrl" should use JS-Java callbacks". r=margaret

This commit is contained in:
vivek 2014-10-31 13:35:00 +01:00
Родитель 472cc70f92
Коммит f94f118757
2 изменённых файлов: 5 добавлений и 15 удалений

Просмотреть файл

@ -1398,7 +1398,7 @@ public class BrowserApp extends GeckoApp
});
} else if ("Feedback:LastUrl".equals(event)) {
getLastUrl();
getLastUrl(callback);
} else if ("Feedback:MaybeLater".equals(event)) {
resetFeedbackLaunchCount();
@ -3017,7 +3017,7 @@ public class BrowserApp extends GeckoApp
settings.edit().putInt(getPackageName() + ".feedback_launch_count", 0).apply();
}
private void getLastUrl() {
private void getLastUrl(final EventCallback callback) {
(new UIAsyncTask.WithoutParams<String>(ThreadUtils.getBackgroundHandler()) {
@Override
public synchronized String doInBackground() {
@ -3038,9 +3038,7 @@ public class BrowserApp extends GeckoApp
@Override
public void onPostExecute(String url) {
// Don't bother sending a message if there is no URL.
if (url.length() > 0)
GeckoAppShell.sendEventToGecko(GeckoEvent.createBroadcastEvent("Feedback:LastUrl", url));
callback.sendSuccess(url);
}
}).execute();
}

Просмотреть файл

@ -58,8 +58,6 @@ function init() {
document.getElementById("sumo-icon").src = helpSectionIcon;
document.getElementById("sad-thanks-icon").src = sadThanksIcon;
window.addEventListener("unload", uninit, false);
document.getElementById("open-play-store").addEventListener("click", openPlayStore, false);
document.forms[0].addEventListener("submit", sendFeedback, false);
for (let anchor of document.querySelectorAll(".no-thanks")) {
@ -76,20 +74,14 @@ function init() {
}, false);
// Fill "Last visited site" input with most recent history entry URL.
Services.obs.addObserver(function observer(aSubject, aTopic, aData) {
Messaging.sendRequestForResult({ type: "Feedback:LastUrl" }).then(function(aData) {
aData = aData.substring(0, 200);
document.getElementById("last-url").value = aData;
// Enable the parent div iff the URL is valid.
if (aData.length != 0) {
document.getElementById("last-url-div").style.display="block";
}
}, "Feedback:LastUrl", false);
Messaging.sendRequest({ type: "Feedback:LastUrl" });
}
function uninit() {
Services.obs.removeObserver(this, "Feedback:LastUrl");
});
}
function switchSection(aSection) {