Bug 1094409 - Explain in the preferences UI the reason when e10s is disabled. r=felipe

This commit is contained in:
Gavin Sharp 2014-11-05 17:01:25 -08:00
Родитель 896e073785
Коммит 480767e56b
2 изменённых файлов: 59 добавлений и 8 удалений

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

@ -92,9 +92,32 @@ var gMainPane = {
setEventListener("e10sAutoStart", "command",
gMainPane.enableE10SChange);
let e10sCheckbox = document.getElementById("e10sAutoStart");
let e10sPref = document.getElementById("browser.tabs.remote.autostart");
let e10sTempPref = document.getElementById("e10sTempPref");
e10sCheckbox.checked = e10sPref.value || e10sTempPref.value;
e10sCheckbox.checked = Services.appinfo.browserTabsRemoteAutostart;
// If e10s is blocked for some reason unrelated to prefs, we want to disable
// the checkbox.
if (!Services.appinfo.browserTabsRemoteAutostart) {
let e10sBlockedReason = Cc["@mozilla.org/supports-string;1"].createInstance(Ci.nsISupportsString);
let appinfo = Services.appinfo.QueryInterface(Ci.nsIObserver);
appinfo.observe(e10sBlockedReason, "getE10SBlocked", "")
if (e10sBlockedReason.data) {
if (e10sBlockedReason.data == "Safe mode") {
// If the only reason we're disabled is because of safe mode, then
// we want to allow the user to un-toggle the pref.
// We're relying on the nsAppRunner code only specifying "Safe mode"
// as the reason if the pref is otherwise enabled, and there are no
// other reasons to block e10s.
// Update the checkbox to reflect the pref state.
e10sCheckbox.checked = true;
} else {
e10sCheckbox.disabled = true;
e10sCheckbox.label += " (disabled: " + e10sBlockedReason.data + ")";
}
}
}
// If E10S is blocked because of safe mode, we want the checkbox to be
// enabled
#endif
#ifdef MOZ_DEV_EDITION

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

@ -615,6 +615,9 @@ bool gSafeMode = false;
* singleton.
*/
class nsXULAppInfo : public nsIXULAppInfo,
#ifdef NIGHTLY_BUILD
public nsIObserver,
#endif
#ifdef XP_WIN
public nsIWinAppHelper,
#endif
@ -630,6 +633,9 @@ public:
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_NSIXULAPPINFO
NS_DECL_NSIXULRUNTIME
#ifdef NIGHTLY_BUILD
NS_DECL_NSIOBSERVER
#endif
#ifdef MOZ_CRASHREPORTER
NS_DECL_NSICRASHREPORTER
NS_DECL_NSIFINISHDUMPINGCALLBACK
@ -642,6 +648,9 @@ public:
NS_INTERFACE_MAP_BEGIN(nsXULAppInfo)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIXULRuntime)
NS_INTERFACE_MAP_ENTRY(nsIXULRuntime)
#ifdef NIGHTLY_BUILD
NS_INTERFACE_MAP_ENTRY(nsIObserver)
#endif
#ifdef XP_WIN
NS_INTERFACE_MAP_ENTRY(nsIWinAppHelper)
#endif
@ -842,8 +851,25 @@ nsXULAppInfo::GetProcessID(uint32_t* aResult)
}
static bool gBrowserTabsRemoteAutostart = false;
static nsString gBrowserTabsRemoteDisabledReason;
static bool gBrowserTabsRemoteAutostartInitialized = false;
#ifdef NIGHTLY_BUILD
NS_IMETHODIMP
nsXULAppInfo::Observe(nsISupports *aSubject, const char *aTopic, const char16_t *aData) {
if (!nsCRT::strcmp(aTopic, "getE10SBlocked")) {
nsCOMPtr<nsISupportsString> ret = do_QueryInterface(aSubject);
if (!ret)
return NS_ERROR_FAILURE;
ret->SetData(gBrowserTabsRemoteDisabledReason);
return NS_OK;
}
return NS_ERROR_FAILURE;
}
#endif
NS_IMETHODIMP
nsXULAppInfo::GetBrowserTabsRemoteAutostart(bool* aResult)
{
@ -4538,8 +4564,10 @@ XRE_GetProcessType()
static void
LogE10sBlockedReason(const char *reason) {
gBrowserTabsRemoteDisabledReason.Assign(NS_ConvertASCIItoUTF16(reason));
nsAutoString msg(NS_LITERAL_STRING("==================\nE10s has been blocked from running because:\n"));
msg.Append(NS_ConvertASCIItoUTF16(reason));
msg.Append(gBrowserTabsRemoteDisabledReason);
msg.AppendLiteral("\n==================\n");
nsCOMPtr<nsIConsoleService> console(do_GetService("@mozilla.org/consoleservice;1"));
if (console) {
@ -4574,11 +4602,11 @@ mozilla::BrowserTabsRemoteAutostart()
if (prefEnabled) {
if (gSafeMode) {
LogE10sBlockedReason("Firefox is in safe mode.");
LogE10sBlockedReason("Safe mode");
} else if (disabledForA11y) {
LogE10sBlockedReason("An accessibility tool is active.");
LogE10sBlockedReason("An accessibility tool is active");
} else if (disabledForIME) {
LogE10sBlockedReason("The keyboard being used has activated IME.");
LogE10sBlockedReason("The keyboard being used has activated IME");
} else {
gBrowserTabsRemoteAutostart = true;
}
@ -4635,7 +4663,7 @@ mozilla::BrowserTabsRemoteAutostart()
if (accelDisabled) {
gBrowserTabsRemoteAutostart = false;
LogE10sBlockedReason("Hardware acceleration is disabled.");
LogE10sBlockedReason("Hardware acceleration is disabled");
}
}
#endif