Bug 936756 - Part 1: remove locale setting from AndroidBridge. Java owns this, not Gecko. r=mfinkle

This commit is contained in:
Richard Newman 2013-12-01 21:53:16 -08:00
Родитель 522a4400c3
Коммит 404ba3b3bd
4 изменённых файлов: 3 добавлений и 83 удалений

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

@ -1586,7 +1586,6 @@ public class GeckoAppShell
}
}
@WrapElementForJNI
public static void setSelectedLocale(String localeCode) {
/* Bug 713464: This method is still called from Gecko side.
Earlier we had an option to run Firefox in a language other than system's language.

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

@ -77,7 +77,6 @@ jmethodID GeckoAppShell::jScheduleRestart = 0;
jmethodID GeckoAppShell::jSendMessageWrapper = 0;
jmethodID GeckoAppShell::jSetFullScreen = 0;
jmethodID GeckoAppShell::jSetKeepScreenOn = 0;
jmethodID GeckoAppShell::jSetSelectedLocale = 0;
jmethodID GeckoAppShell::jSetURITitle = 0;
jmethodID GeckoAppShell::jShowAlertNotificationWrapper = 0;
jmethodID GeckoAppShell::jShowFilePickerAsyncWrapper = 0;
@ -158,7 +157,6 @@ void GeckoAppShell::InitStubs(JNIEnv *jEnv) {
jSendMessageWrapper = getStaticMethod("sendMessage", "(Ljava/lang/String;Ljava/lang/String;I)V");
jSetFullScreen = getStaticMethod("setFullScreen", "(Z)V");
jSetKeepScreenOn = getStaticMethod("setKeepScreenOn", "(Z)V");
jSetSelectedLocale = getStaticMethod("setSelectedLocale", "(Ljava/lang/String;)V");
jSetURITitle = getStaticMethod("setUriTitle", "(Ljava/lang/String;Ljava/lang/String;)V");
jShowAlertNotificationWrapper = getStaticMethod("showAlertNotification", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V");
jShowFilePickerAsyncWrapper = getStaticMethod("showFilePickerAsync", "(Ljava/lang/String;J)V");
@ -2055,35 +2053,6 @@ void GeckoAppShell::SetKeepScreenOn(bool a0) {
env->PopLocalFrame(NULL);
}
void GeckoAppShell::SetSelectedLocale(const nsAString& a0) {
JNIEnv *env = AndroidBridge::GetJNIEnv();
if (!env) {
ALOG_BRIDGE("Aborted: No env - %s", __PRETTY_FUNCTION__);
return;
}
if (env->PushLocalFrame(1) != 0) {
ALOG_BRIDGE("Exceptional exit of: %s", __PRETTY_FUNCTION__);
env->ExceptionDescribe();
env->ExceptionClear();
return;
}
jstring j0 = AndroidBridge::NewJavaString(env, a0);
env->CallStaticVoidMethod(mGeckoAppShellClass, jSetSelectedLocale, j0);
if (env->ExceptionCheck()) {
ALOG_BRIDGE("Exceptional exit of: %s", __PRETTY_FUNCTION__);
env->ExceptionDescribe();
env->ExceptionClear();
env->PopLocalFrame(NULL);
return;
}
env->PopLocalFrame(NULL);
}
void GeckoAppShell::SetURITitle(const nsAString& a0, const nsAString& a1) {
JNIEnv *env = AndroidBridge::GetJNIEnv();
if (!env) {

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

@ -84,7 +84,6 @@ public:
static void SendMessageWrapper(const nsAString& a0, const nsAString& a1, int32_t a2);
static void SetFullScreen(bool a0);
static void SetKeepScreenOn(bool a0);
static void SetSelectedLocale(const nsAString& a0);
static void SetURITitle(const nsAString& a0, const nsAString& a1);
static void ShowAlertNotificationWrapper(const nsAString& a0, const nsAString& a1, const nsAString& a2, const nsAString& a3, const nsAString& a4);
static void ShowFilePickerAsyncWrapper(const nsAString& a0, int64_t a1);

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

@ -163,12 +163,8 @@ nsAppShell::NotifyNativeEvent()
mQueueCond.Notify();
}
#define PREFNAME_MATCH_OS "intl.locale.matchOS"
#define PREFNAME_UA_LOCALE "general.useragent.locale"
#define PREFNAME_COALESCE_TOUCHES "dom.event.touch.coalescing.enabled"
static const char* kObservedPrefs[] = {
PREFNAME_MATCH_OS,
PREFNAME_UA_LOCALE,
PREFNAME_COALESCE_TOUCHES,
nullptr
};
@ -182,8 +178,6 @@ nsAppShell::Init()
#endif
nsresult rv = nsBaseAppShell::Init();
AndroidBridge* bridge = AndroidBridge::Bridge();
nsCOMPtr<nsIObserverService> obsServ =
mozilla::services::GetObserverService();
if (obsServ) {
@ -193,27 +187,7 @@ nsAppShell::Init()
if (sPowerManagerService)
sPowerManagerService->AddWakeLockListener(sWakeLockListener);
if (!bridge)
return rv;
Preferences::AddStrongObservers(this, kObservedPrefs);
bool match;
rv = Preferences::GetBool(PREFNAME_MATCH_OS, &match);
NS_ENSURE_SUCCESS(rv, rv);
if (match) {
GeckoAppShell::SetSelectedLocale(EmptyString());
return NS_OK;
}
nsAutoString locale;
rv = Preferences::GetLocalizedString(PREFNAME_UA_LOCALE, &locale);
if (NS_FAILED(rv)) {
rv = Preferences::GetString(PREFNAME_UA_LOCALE, &locale);
}
GeckoAppShell::SetSelectedLocale(locale);
mAllowCoalescingTouches = Preferences::GetBool(PREFNAME_COALESCE_TOUCHES, true);
return rv;
}
@ -228,30 +202,9 @@ nsAppShell::Observe(nsISupports* aSubject,
// or we'll see crashes, as the app shell outlives XPConnect.
mObserversHash.Clear();
return nsBaseAppShell::Observe(aSubject, aTopic, aData);
} else if (!strcmp(aTopic, NS_PREFBRANCH_PREFCHANGE_TOPIC_ID) && aData && (
nsDependentString(aData).Equals(
NS_LITERAL_STRING(PREFNAME_UA_LOCALE)) ||
nsDependentString(aData).Equals(
NS_LITERAL_STRING(PREFNAME_COALESCE_TOUCHES)) ||
nsDependentString(aData).Equals(
NS_LITERAL_STRING(PREFNAME_MATCH_OS)))) {
bool match;
nsresult rv = Preferences::GetBool(PREFNAME_MATCH_OS, &match);
NS_ENSURE_SUCCESS(rv, rv);
if (match) {
GeckoAppShell::SetSelectedLocale(EmptyString());
return NS_OK;
}
nsAutoString locale;
if (NS_FAILED(Preferences::GetLocalizedString(PREFNAME_UA_LOCALE,
&locale))) {
locale = Preferences::GetString(PREFNAME_UA_LOCALE);
}
GeckoAppShell::SetSelectedLocale(locale);
} else if (!strcmp(aTopic, NS_PREFBRANCH_PREFCHANGE_TOPIC_ID) &&
aData &&
nsDependentString(aData).Equals(NS_LITERAL_STRING(PREFNAME_COALESCE_TOUCHES))) {
mAllowCoalescingTouches = Preferences::GetBool(PREFNAME_COALESCE_TOUCHES, true);
return NS_OK;
}