mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 999488 - Move reader mode related listener registration from GeckoApp to BrowserApp. r=margaret
This commit is contained in:
parent
eac4fd78f2
commit
2138a01870
@ -418,6 +418,31 @@ abstract public class BrowserApp extends GeckoApp
|
||||
});
|
||||
}
|
||||
|
||||
private void handleReaderFaviconRequest(final String url) {
|
||||
(new UiAsyncTask<Void, Void, String>(ThreadUtils.getBackgroundHandler()) {
|
||||
@Override
|
||||
public String doInBackground(Void... params) {
|
||||
return Favicons.getFaviconURLForPageURL(url);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPostExecute(String faviconUrl) {
|
||||
JSONObject args = new JSONObject();
|
||||
|
||||
if (faviconUrl != null) {
|
||||
try {
|
||||
args.put("url", url);
|
||||
args.put("faviconUrl", faviconUrl);
|
||||
} catch (JSONException e) {
|
||||
Log.w(LOGTAG, "Error building JSON favicon arguments.", e);
|
||||
}
|
||||
}
|
||||
|
||||
GeckoAppShell.sendEventToGecko(GeckoEvent.createBroadcastEvent("Reader:FaviconReturn", args.toString()));
|
||||
}
|
||||
}).execute();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
mAboutHomeStartupTimer = new Telemetry.UptimeTimer("FENNEC_STARTUP_TIME_ABOUTHOME");
|
||||
@ -497,6 +522,11 @@ abstract public class BrowserApp extends GeckoApp
|
||||
registerEventListener("Accounts:Create");
|
||||
registerEventListener("Accounts:Exist");
|
||||
registerEventListener("Prompt:ShowTop");
|
||||
registerEventListener("Reader:ListStatusRequest");
|
||||
registerEventListener("Reader:Added");
|
||||
registerEventListener("Reader:Removed");
|
||||
registerEventListener("Reader:Share");
|
||||
registerEventListener("Reader:FaviconRequest");
|
||||
|
||||
Distribution.init(this);
|
||||
JavaAddonManager.getInstance().init(getApplicationContext());
|
||||
@ -843,6 +873,11 @@ abstract public class BrowserApp extends GeckoApp
|
||||
unregisterEventListener("Menu:Update");
|
||||
unregisterEventListener("Accounts:Create");
|
||||
unregisterEventListener("Accounts:Exist");
|
||||
unregisterEventListener("Reader:ListStatusRequest");
|
||||
unregisterEventListener("Reader:Added");
|
||||
unregisterEventListener("Reader:Removed");
|
||||
unregisterEventListener("Reader:Share");
|
||||
unregisterEventListener("Reader:FaviconRequest");
|
||||
|
||||
if (AppConstants.MOZ_ANDROID_BEAM && Build.VERSION.SDK_INT >= 14) {
|
||||
NfcAdapter nfc = NfcAdapter.getDefaultAdapter(this);
|
||||
@ -1206,6 +1241,9 @@ abstract public class BrowserApp extends GeckoApp
|
||||
final String url = message.getString("url");
|
||||
GeckoAppShell.openUriExternal(url, "text/plain", "", "",
|
||||
Intent.ACTION_SEND, title);
|
||||
} else if (event.equals("Reader:FaviconRequest")) {
|
||||
final String url = message.getString("url");
|
||||
handleReaderFaviconRequest(url);
|
||||
} else if (event.equals("Settings:Show")) {
|
||||
// null strings return "null" (http://code.google.com/p/android/issues/detail?id=13830)
|
||||
String resource = null;
|
||||
|
@ -496,31 +496,6 @@ public abstract class GeckoApp
|
||||
outState.putString(SAVED_STATE_PRIVATE_SESSION, mPrivateBrowsingSession);
|
||||
}
|
||||
|
||||
void handleFaviconRequest(final String url) {
|
||||
(new UiAsyncTask<Void, Void, String>(ThreadUtils.getBackgroundHandler()) {
|
||||
@Override
|
||||
public String doInBackground(Void... params) {
|
||||
return Favicons.getFaviconURLForPageURL(url);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPostExecute(String faviconUrl) {
|
||||
JSONObject args = new JSONObject();
|
||||
|
||||
if (faviconUrl != null) {
|
||||
try {
|
||||
args.put("url", url);
|
||||
args.put("faviconUrl", faviconUrl);
|
||||
} catch (JSONException e) {
|
||||
Log.w(LOGTAG, "Error building JSON favicon arguments.", e);
|
||||
}
|
||||
}
|
||||
|
||||
GeckoAppShell.sendEventToGecko(GeckoEvent.createBroadcastEvent("Reader:FaviconReturn", args.toString()));
|
||||
}
|
||||
}).execute();
|
||||
}
|
||||
|
||||
void handleClearHistory() {
|
||||
BrowserDB.clearHistory(getContentResolver());
|
||||
}
|
||||
@ -565,9 +540,6 @@ public abstract class GeckoApp
|
||||
// generic log listener
|
||||
final String msg = message.getString("msg");
|
||||
Log.d(LOGTAG, "Log: " + msg);
|
||||
} else if (event.equals("Reader:FaviconRequest")) {
|
||||
final String url = message.getString("url");
|
||||
handleFaviconRequest(url);
|
||||
} else if (event.equals("Gecko:DelayedStartup")) {
|
||||
ThreadUtils.postToBackgroundThread(new UninstallListener.DelayedStartupTask(this));
|
||||
} else if (event.equals("Gecko:Ready")) {
|
||||
@ -1573,11 +1545,6 @@ public abstract class GeckoApp
|
||||
|
||||
//register for events
|
||||
registerEventListener("log");
|
||||
registerEventListener("Reader:ListStatusRequest");
|
||||
registerEventListener("Reader:Added");
|
||||
registerEventListener("Reader:Removed");
|
||||
registerEventListener("Reader:Share");
|
||||
registerEventListener("Reader:FaviconRequest");
|
||||
registerEventListener("onCameraCapture");
|
||||
registerEventListener("Gecko:Ready");
|
||||
registerEventListener("Gecko:DelayedStartup");
|
||||
@ -2114,11 +2081,6 @@ public abstract class GeckoApp
|
||||
public void onDestroy()
|
||||
{
|
||||
unregisterEventListener("log");
|
||||
unregisterEventListener("Reader:ListStatusRequest");
|
||||
unregisterEventListener("Reader:Added");
|
||||
unregisterEventListener("Reader:Removed");
|
||||
unregisterEventListener("Reader:Share");
|
||||
unregisterEventListener("Reader:FaviconRequest");
|
||||
unregisterEventListener("onCameraCapture");
|
||||
unregisterEventListener("Gecko:Ready");
|
||||
unregisterEventListener("Gecko:DelayedStartup");
|
||||
|
Loading…
Reference in New Issue
Block a user