Bug 1071203 - Log a message to the console when we override browser.tabs.remote.autostart. r=billm

This commit is contained in:
Felipe Gomes 2014-09-29 22:22:21 -03:00
parent 3b336bf2cf
commit bbbe163c3b

View File

@ -4556,6 +4556,17 @@ XRE_GetProcessType()
return mozilla::startup::sChildProcessType;
}
static void
LogE10sBlockedReason(const char *reason) {
nsAutoString msg(NS_LITERAL_STRING("==================\nE10s has been blocked from running because:\n"));
msg.Append(NS_ConvertASCIItoUTF16(reason));
msg.AppendLiteral("\n==================\n");
nsCOMPtr<nsIConsoleService> console(do_GetService("@mozilla.org/consoleservice;1"));
if (console) {
console->LogStringMessage(msg.get());
}
}
bool
mozilla::BrowserTabsRemoteAutostart()
{
@ -4563,11 +4574,26 @@ mozilla::BrowserTabsRemoteAutostart()
return false;
#endif
if (!gBrowserTabsRemoteAutostartInitialized) {
bool hasIME = KeyboardMayHaveIME();
bool prefEnabled = Preferences::GetBool("browser.tabs.remote.autostart", false) ||
(Preferences::GetBool("browser.tabs.remote.autostart.1", false) && !hasIME);
bool optInPref = Preferences::GetBool("browser.tabs.remote.autostart", false);
bool trialPref = Preferences::GetBool("browser.tabs.remote.autostart.1", false);
bool prefEnabled = optInPref || trialPref;
bool disabledForA11y = Preferences::GetBool("browser.tabs.remote.autostart.disabled-because-using-a11y", false);
gBrowserTabsRemoteAutostart = !gSafeMode && !disabledForA11y && prefEnabled;
// Only disable for IME for the automatic pref, not the opt-in one.
bool disabledForIME = trialPref && KeyboardMayHaveIME();
if (prefEnabled) {
if (gSafeMode) {
LogE10sBlockedReason("Firefox is in safe mode.");
} else if (disabledForA11y) {
LogE10sBlockedReason("An accessibility tool is active.");
} else if (disabledForIME) {
LogE10sBlockedReason("The keyboard being used has activated IME.");
} else {
gBrowserTabsRemoteAutostart = true;
}
}
#if defined(XP_WIN) || defined(XP_MACOSX)
// If for any reason we suspect acceleration will be disabled, disabled
@ -4576,13 +4602,6 @@ mozilla::BrowserTabsRemoteAutostart()
// Check prefs
bool accelDisabled = Preferences::GetBool("layers.acceleration.disabled", false) &&
!Preferences::GetBool("layers.acceleration.force-enabled", false);
// Check env flags
if (!accelDisabled) {
const char *acceleratedEnv = PR_GetEnv("MOZ_ACCELERATED");
if (acceleratedEnv && (*acceleratedEnv != '0')) {
accelDisabled = false;
}
}
#if defined(XP_MACOSX)
accelDisabled = !nsCocoaFeatures::AccelerateByDefault();
@ -4615,8 +4634,18 @@ mozilla::BrowserTabsRemoteAutostart()
}
}
}
// Check env flags
if (accelDisabled) {
const char *acceleratedEnv = PR_GetEnv("MOZ_ACCELERATED");
if (acceleratedEnv && (*acceleratedEnv != '0')) {
accelDisabled = false;
}
}
if (accelDisabled) {
gBrowserTabsRemoteAutostart = false;
LogE10sBlockedReason("Hardware acceleration is disabled.");
}
}
#endif