Bug 1366808: Add about:restartrequired page for situations when a background update has occurred and restarting Firefox is required to continue. r=felipe

This commit is contained in:
Stephen A Pohl 2018-05-08 10:31:37 -04:00
parent 03cb623ee0
commit b5c7b7b14c
10 changed files with 151 additions and 1 deletions

View File

@ -0,0 +1,33 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/* eslint-env mozilla/frame-script */
ChromeUtils.import("resource://gre/modules/Services.jsm");
var AboutRestartRequired = {
/* Only do autofocus if we're the toplevel frame; otherwise we
don't want to call attention to ourselves! The key part is
that autofocus happens on insertion into the tree, so we
can remove the button, add @autofocus, and reinsert the
button.
*/
addAutofocus() {
if (window.top == window) {
var button = document.getElementById("restart");
var parent = button.parentNode;
button.remove();
button.setAttribute("autofocus", "true");
parent.insertAdjacentElement("afterbegin", button);
}
},
restart() {
Services.startup.quit(Ci.nsIAppStartup.eRestart |
Ci.nsIAppStartup.eAttemptQuit);
},
init() {
this.addAutofocus();
},
};
AboutRestartRequired.init();

View File

@ -0,0 +1,56 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
<!DOCTYPE html [
<!ENTITY % htmlDTD
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"DTD/xhtml1-strict.dtd">
%htmlDTD;
<!ENTITY % globalDTD
SYSTEM "chrome://global/locale/global.dtd">
%globalDTD;
<!ENTITY % brandDTD SYSTEM "chrome://branding/locale/brand.dtd" >
%brandDTD;
<!ENTITY % restartRequiredDTD
SYSTEM "chrome://browser/locale/aboutRestartRequired.dtd">
%restartRequiredDTD;
]>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>&restartRequired.title;</title>
<link rel="stylesheet" type="text/css" media="all"
href="chrome://browser/skin/aboutRestartRequired.css"/>
<!-- If the location of the favicon is changed here, the
FAVICON_ERRORPAGE_URL symbol in
toolkit/components/places/src/nsFaviconService.h should be updated. -->
<link rel="icon" type="image/png" id="favicon"
href="chrome://global/skin/icons/warning-16.png"/>
</head>
<body dir="&locale.dir;">
<!-- PAGE CONTAINER (for styling purposes only) -->
<div id="errorPageContainer">
<div id="text-container">
<div id="title">
<h1 id="title-text">&restartRequired.header;</h1>
</div>
<div id="errorLongContent">
<div id="errorLongDesc">&restartRequired.description;</div>
</div>
</div>
<!-- Restart Button -->
<div id="restartButtonContainer" class="button-container">
<button id="restart" class="primary" autocomplete="off"
onclick="AboutRestartRequired.restart();">
&restartButton.label;
</button>
</div>
</div>
</body>
<script type="text/javascript"
src="chrome://browser/content/aboutRestartRequired.js"/>
</html>

View File

@ -8,6 +8,8 @@ browser.jar:
* content/browser/aboutDialog.xul (content/aboutDialog.xul)
content/browser/aboutDialog.js (content/aboutDialog.js)
content/browser/aboutDialog.css (content/aboutDialog.css)
content/browser/aboutRestartRequired.js (content/aboutRestartRequired.js)
content/browser/aboutRestartRequired.xhtml (content/aboutRestartRequired.xhtml)
content/browser/aboutRobots.xhtml (content/aboutRobots.xhtml)
content/browser/aboutRobots.js (content/aboutRobots.js)
content/browser/aboutRobots.css (content/aboutRobots.css)

View File

@ -98,6 +98,8 @@ static const RedirEntry kRedirMap[] = {
nsIAboutModule::ALLOW_SCRIPT |
nsIAboutModule::URI_MUST_LOAD_IN_CHILD |
nsIAboutModule::HIDE_FROM_ABOUTABOUT },
{ "restartrequired", "chrome://browser/content/aboutRestartRequired.xhtml",
nsIAboutModule::ALLOW_SCRIPT },
};
static nsAutoCString

View File

@ -100,6 +100,7 @@ static const mozilla::Module::ContractIDEntry kBrowserContracts[] = {
{ NS_ABOUT_MODULE_CONTRACTID_PREFIX "preferences", &kNS_BROWSER_ABOUT_REDIRECTOR_CID },
{ NS_ABOUT_MODULE_CONTRACTID_PREFIX "downloads", &kNS_BROWSER_ABOUT_REDIRECTOR_CID },
{ NS_ABOUT_MODULE_CONTRACTID_PREFIX "reader", &kNS_BROWSER_ABOUT_REDIRECTOR_CID },
{ NS_ABOUT_MODULE_CONTRACTID_PREFIX "restartrequired", &kNS_BROWSER_ABOUT_REDIRECTOR_CID },
#if defined(XP_WIN)
{ NS_IEHISTORYENUMERATOR_CONTRACTID, &kNS_WINIEHISTORYENUMERATOR_CID },
#elif defined(XP_MACOSX)

View File

@ -0,0 +1,13 @@
<!-- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
<!ENTITY restartRequired.title "Restart Required">
<!ENTITY restartRequired.header "Sorry. We just need to do one small thing to keep going.">
<!ENTITY restartRequired.description "
<p>We have just installed an update in the background. Click Restart &brandShortName; to finish applying it.</p>
<p>We will restore all your pages, windows and tabs afterwards, so you can be on your way quickly.</p>
">
<!ENTITY restartButton.label "Restart &brandShortName;">

View File

@ -18,6 +18,7 @@
locale/browser/aboutRobots.dtd (%chrome/browser/aboutRobots.dtd)
locale/browser/aboutHome.dtd (%chrome/browser/aboutHome.dtd)
locale/browser/accounts.properties (%chrome/browser/accounts.properties)
locale/browser/aboutRestartRequired.dtd (%chrome/browser/aboutRestartRequired.dtd)
locale/browser/aboutSearchReset.dtd (%chrome/browser/aboutSearchReset.dtd)
locale/browser/aboutSessionRestore.dtd (%chrome/browser/aboutSessionRestore.dtd)
locale/browser/aboutTabCrashed.dtd (%chrome/browser/aboutTabCrashed.dtd)

View File

@ -0,0 +1,41 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
@import url("chrome://browser/skin/error-pages.css");
.illustrated #errorPageContainer {
min-height: 300px;
display: flex;
flex-direction: column;
background-position: left center;
}
body[dir="rtl"] #errorPageContainer {
background-position: right center;
}
#header {
background: none;
padding-inline-start: 0;
margin-inline-start: 0;
}
#text-container {
margin: auto;
padding-inline-start: 38%;
}
#errorPageContainer {
min-height: 350px;
display: flex;
flex-direction: column;
background-position: left center;
background-repeat: no-repeat;
background-size: 38%;
background-image: url("chrome://browser/content/illustrations/error-connection-failure.svg");
}
#restart {
margin-top: 1.2em;
}

View File

@ -10,6 +10,7 @@
skin/classic/browser/aboutNetError.css (../shared/aboutNetError.css)
skin/classic/browser/blockedSite.css (../shared/blockedSite.css)
skin/classic/browser/error-pages.css (../shared/error-pages.css)
skin/classic/browser/aboutRestartRequired.css (../shared/aboutRestartRequired.css)
* skin/classic/browser/aboutSessionRestore.css (../shared/aboutSessionRestore.css)
skin/classic/browser/aboutLibrary.css (../shared/aboutLibrary.css)
skin/classic/browser/aboutTabCrashed.css (../shared/aboutTabCrashed.css)

View File

@ -205,7 +205,7 @@ interface nsILoadInfo : nsISupports
/**
* Load an error page, it should be one of following : about:neterror,
* about:certerror, about:blocked, or about:tabcrashed.
* about:certerror, about:blocked, about:tabcrashed or about:restartrequired.
*/
const unsigned long SEC_LOAD_ERROR_PAGE = (1<<13);