зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1388145 - Move the default browser check to an idle callback. r=florian
Note that the DefaultBrowserCheck.prompt() was scheduled with an idle callback before and it was removed here, because it's no longer necessary (as the entire function is now running from an idle callback) MozReview-Commit-ID: GQQbAlBn2UI --HG-- extra : rebase_source : e317326c3dc4a47f87ba86b29dc3dbdec2657f33
This commit is contained in:
Родитель
ad0d65f131
Коммит
2b65729455
|
@ -1104,81 +1104,6 @@ BrowserGlue.prototype = {
|
|||
this._notifyDisabledNonMpc();
|
||||
}
|
||||
|
||||
// Perform default browser checking.
|
||||
if (ShellService) {
|
||||
let shouldCheck = AppConstants.DEBUG ? false :
|
||||
ShellService.shouldCheckDefaultBrowser;
|
||||
|
||||
const skipDefaultBrowserCheck =
|
||||
Services.prefs.getBoolPref("browser.shell.skipDefaultBrowserCheckOnFirstRun") &&
|
||||
!Services.prefs.getBoolPref("browser.shell.didSkipDefaultBrowserCheckOnFirstRun");
|
||||
|
||||
const usePromptLimit = !AppConstants.RELEASE_OR_BETA;
|
||||
let promptCount =
|
||||
usePromptLimit ? Services.prefs.getIntPref("browser.shell.defaultBrowserCheckCount") : 0;
|
||||
|
||||
let willRecoverSession = false;
|
||||
try {
|
||||
let ss = Cc["@mozilla.org/browser/sessionstartup;1"].
|
||||
getService(Ci.nsISessionStartup);
|
||||
willRecoverSession =
|
||||
(ss.sessionType == Ci.nsISessionStartup.RECOVER_SESSION);
|
||||
} catch (ex) { /* never mind; suppose SessionStore is broken */ }
|
||||
|
||||
// startup check, check all assoc
|
||||
let isDefault = false;
|
||||
let isDefaultError = false;
|
||||
try {
|
||||
isDefault = ShellService.isDefaultBrowser(true, false);
|
||||
} catch (ex) {
|
||||
isDefaultError = true;
|
||||
}
|
||||
|
||||
if (isDefault) {
|
||||
let now = (Math.floor(Date.now() / 1000)).toString();
|
||||
Services.prefs.setCharPref("browser.shell.mostRecentDateSetAsDefault", now);
|
||||
}
|
||||
|
||||
let willPrompt = shouldCheck && !isDefault && !willRecoverSession;
|
||||
|
||||
// Skip the "Set Default Browser" check during first-run or after the
|
||||
// browser has been run a few times.
|
||||
if (willPrompt) {
|
||||
if (skipDefaultBrowserCheck) {
|
||||
Services.prefs.setBoolPref("browser.shell.didSkipDefaultBrowserCheckOnFirstRun", true);
|
||||
willPrompt = false;
|
||||
} else {
|
||||
promptCount++;
|
||||
}
|
||||
if (usePromptLimit && promptCount > 3) {
|
||||
willPrompt = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (usePromptLimit && willPrompt) {
|
||||
Services.prefs.setIntPref("browser.shell.defaultBrowserCheckCount", promptCount);
|
||||
}
|
||||
|
||||
try {
|
||||
// Report default browser status on startup to telemetry
|
||||
// so we can track whether we are the default.
|
||||
Services.telemetry.getHistogramById("BROWSER_IS_USER_DEFAULT")
|
||||
.add(isDefault);
|
||||
Services.telemetry.getHistogramById("BROWSER_IS_USER_DEFAULT_ERROR")
|
||||
.add(isDefaultError);
|
||||
Services.telemetry.getHistogramById("BROWSER_SET_DEFAULT_ALWAYS_CHECK")
|
||||
.add(shouldCheck);
|
||||
Services.telemetry.getHistogramById("BROWSER_SET_DEFAULT_DIALOG_PROMPT_RAWCOUNT")
|
||||
.add(promptCount);
|
||||
} catch (ex) { /* Don't break the default prompt if telemetry is broken. */ }
|
||||
|
||||
if (willPrompt) {
|
||||
Services.tm.dispatchToMainThread(function() {
|
||||
DefaultBrowserCheck.prompt(RecentWindow.getMostRecentBrowserWindow());
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (AppConstants.MOZ_CRASHREPORTER) {
|
||||
UnsubmittedCrashHandler.init();
|
||||
Services.tm.idleDispatchToMainThread(function() {
|
||||
|
@ -1233,6 +1158,10 @@ BrowserGlue.prototype = {
|
|||
Services.tm.idleDispatchToMainThread(() => {
|
||||
SafeBrowsing.init();
|
||||
}, 5000);
|
||||
|
||||
Services.tm.idleDispatchToMainThread(() => {
|
||||
this._checkForDefaultBrowser();
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -2163,6 +2092,83 @@ BrowserGlue.prototype = {
|
|||
Services.prefs.setIntPref("browser.migration.version", UI_VERSION);
|
||||
},
|
||||
|
||||
_checkForDefaultBrowser() {
|
||||
// Perform default browser checking.
|
||||
if (!ShellService) {
|
||||
return;
|
||||
}
|
||||
|
||||
let shouldCheck = AppConstants.DEBUG ? false :
|
||||
ShellService.shouldCheckDefaultBrowser;
|
||||
|
||||
const skipDefaultBrowserCheck =
|
||||
Services.prefs.getBoolPref("browser.shell.skipDefaultBrowserCheckOnFirstRun") &&
|
||||
!Services.prefs.getBoolPref("browser.shell.didSkipDefaultBrowserCheckOnFirstRun");
|
||||
|
||||
const usePromptLimit = !AppConstants.RELEASE_OR_BETA;
|
||||
let promptCount =
|
||||
usePromptLimit ? Services.prefs.getIntPref("browser.shell.defaultBrowserCheckCount") : 0;
|
||||
|
||||
let willRecoverSession = false;
|
||||
try {
|
||||
let ss = Cc["@mozilla.org/browser/sessionstartup;1"].
|
||||
getService(Ci.nsISessionStartup);
|
||||
willRecoverSession =
|
||||
(ss.sessionType == Ci.nsISessionStartup.RECOVER_SESSION);
|
||||
} catch (ex) { /* never mind; suppose SessionStore is broken */ }
|
||||
|
||||
// startup check, check all assoc
|
||||
let isDefault = false;
|
||||
let isDefaultError = false;
|
||||
try {
|
||||
isDefault = ShellService.isDefaultBrowser(true, false);
|
||||
} catch (ex) {
|
||||
isDefaultError = true;
|
||||
}
|
||||
|
||||
if (isDefault) {
|
||||
let now = (Math.floor(Date.now() / 1000)).toString();
|
||||
Services.prefs.setCharPref("browser.shell.mostRecentDateSetAsDefault", now);
|
||||
}
|
||||
|
||||
let willPrompt = shouldCheck && !isDefault && !willRecoverSession;
|
||||
|
||||
// Skip the "Set Default Browser" check during first-run or after the
|
||||
// browser has been run a few times.
|
||||
if (willPrompt) {
|
||||
if (skipDefaultBrowserCheck) {
|
||||
Services.prefs.setBoolPref("browser.shell.didSkipDefaultBrowserCheckOnFirstRun", true);
|
||||
willPrompt = false;
|
||||
} else {
|
||||
promptCount++;
|
||||
}
|
||||
if (usePromptLimit && promptCount > 3) {
|
||||
willPrompt = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (usePromptLimit && willPrompt) {
|
||||
Services.prefs.setIntPref("browser.shell.defaultBrowserCheckCount", promptCount);
|
||||
}
|
||||
|
||||
try {
|
||||
// Report default browser status on startup to telemetry
|
||||
// so we can track whether we are the default.
|
||||
Services.telemetry.getHistogramById("BROWSER_IS_USER_DEFAULT")
|
||||
.add(isDefault);
|
||||
Services.telemetry.getHistogramById("BROWSER_IS_USER_DEFAULT_ERROR")
|
||||
.add(isDefaultError);
|
||||
Services.telemetry.getHistogramById("BROWSER_SET_DEFAULT_ALWAYS_CHECK")
|
||||
.add(shouldCheck);
|
||||
Services.telemetry.getHistogramById("BROWSER_SET_DEFAULT_DIALOG_PROMPT_RAWCOUNT")
|
||||
.add(promptCount);
|
||||
} catch (ex) { /* Don't break the default prompt if telemetry is broken. */ }
|
||||
|
||||
if (willPrompt) {
|
||||
DefaultBrowserCheck.prompt(RecentWindow.getMostRecentBrowserWindow());
|
||||
}
|
||||
},
|
||||
|
||||
// ------------------------------
|
||||
// public nsIBrowserGlue members
|
||||
// ------------------------------
|
||||
|
|
Загрузка…
Ссылка в новой задаче