Bug 593421 - Provide link to "Restore Previous Session" on Firefox Start [r=gavin, r=ehsan, a=blocking2.0:betaN+]

This commit is contained in:
Paul O’Shannessy ext:(%2C%20Mihai%20Sucan%20%3Cmihai.sucan%40gmail.com%3E) 2011-01-31 17:05:31 -08:00
parent 890ade8674
commit e27f14192a
6 changed files with 138 additions and 0 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

View File

@ -265,6 +265,111 @@ body[dir=rtl] #searchSubmit:active {
0 1px 0 rgba(255,255,255,.5);
}
#sessionRestoreContainer {
padding-top: 1.5%;
height: 33%;
text-align: center;
}
@media all and (max-height: 370px) {
#sessionRestoreContainer {
position: relative;
top: -5px;
padding-top: 0;
}
}
#restorePreviousSession {
-moz-padding-start: 7.5%;
-moz-padding-end: 10px;
height: 100%;
border: 0;
border-radius: 4px;
box-shadow: 0 0 0 1px rgba(9,37,59,0),
0 1px 2px rgba(9,37,59,0),
0 0 10px rgba(255,255,255,0),
0 -3px 0 rgba(180,194,212,0) inset;
-moz-transition-property: background-color, box-shadow;
-moz-transition-duration: 0.25s;
-moz-transition-timing-function: ease-out;
background: transparent url("chrome://browser/content/aboutHome-restore-icon.png") no-repeat 10px 50%;
background-size: auto 77%;
color: rgb(50,50,50);
font-weight: bold;
}
body[dir=rtl] #restorePreviousSession {
background-image: url("chrome://browser/content/aboutHome-restore-icon-rtl.png");
background-position: 100% 50%;
}
@media all and (max-aspect-ratio: 8/16) {
#restorePreviousSession { -moz-padding-start: 25% }
}
@media all and (min-aspect-ratio: 8/16) and (max-aspect-ratio: 10/16) {
#restorePreviousSession { -moz-padding-start: 18% }
}
@media all and (min-aspect-ratio: 10/16) and (max-aspect-ratio: 12/16) {
#restorePreviousSession { -moz-padding-start: 15% }
}
@media all and (min-aspect-ratio: 12/16) and (max-aspect-ratio: 15/16) {
#restorePreviousSession { -moz-padding-start: 12% }
}
@media all and (min-aspect-ratio: 15/16) and (max-aspect-ratio: 20/16) {
#restorePreviousSession { -moz-padding-start: 9% }
}
@media all and (min-aspect-ratio: 31/16) and (max-aspect-ratio: 51/16) {
#restorePreviousSession { -moz-padding-start: 5% }
}
@media all and (min-aspect-ratio: 51/16) {
#restorePreviousSession { -moz-padding-start: 3% }
}
#restorePreviousSession:disabled {
display: none;
}
#restorePreviousSession:hover {
background-image: url("chrome://browser/content/aboutHome-restore-icon.png"),
-moz-linear-gradient(rgba(255,255,255,.7), rgba(255,255,255,.2));
background-position: 10px 50%, 0 0;
background-size: auto 77%, auto auto;
border-radius: 4px;
box-shadow: 0 0 0 1px rgba(9,37,59,.2),
0 1px 2px rgba(9,37,59,.2),
0 0 10px rgba(255,255,255,.4),
0 -3px 0 rgba(180,194,212,.3) inset;
}
body[dir=rtl] #restorePreviousSession:hover {
background-image: url("chrome://browser/content/aboutHome-restore-icon-rtl.png"),
-moz-linear-gradient(rgba(255,255,255,.7), rgba(255,255,255,.2));
background-position: 100% 50%, 0 0;
}
#restorePreviousSession:hover:active {
background-image: url("chrome://browser/content/aboutHome-restore-icon.png"),
-moz-linear-gradient(rgba(255,255,255,.0), rgba(255,255,255,.2));
background-position: 10px 50%, 0 0;
background-size: auto 77%, auto auto;
background-color: rgba(23,75,115,.1);
box-shadow: 0 0 0 1px rgba(9,37,59,.2),
0 1px 2px rgba(9,37,59,.4) inset,
0 1px 5px rgba(9,37,59,.15) inset;
}
body[dir=rtl] #restorePreviousSession:hover:active {
background-image: url("chrome://browser/content/aboutHome-restore-icon-rtl.png"),
-moz-linear-gradient(rgba(255,255,255,.0), rgba(255,255,255,.2));
background-position: 100% 50%, 0 0;
}
#bottomSection {
position: absolute;
color: rgb(150,150,150);

View File

@ -49,6 +49,8 @@
%globalDTD;
<!ENTITY % aboutHomeDTD SYSTEM "chrome://browser/locale/aboutHome.dtd">
%aboutHomeDTD;
<!ENTITY % browserDTD SYSTEM "chrome://browser/locale/browser.dtd" >
%browserDTD;
]>
<html xmlns="http://www.w3.org/1999/xhtml">
@ -95,6 +97,10 @@
<div id="snippets" hidden="true"/>
</div>
<div id="sessionRestoreContainer">
<button id="restorePreviousSession">&historyRestoreLastSession.label;</button>
</div>
</div>
<div id="bottomSection">

View File

@ -2550,6 +2550,19 @@ function BrowserImport()
#endif
}
/**
* Handle load of some pages (about:*) so that we can make modifications
* to the DOM for unprivileged pages.
*/
function BrowserOnAboutPageLoad(document) {
if (/^about:home$/i.test(document.documentURI)) {
let ss = Components.classes["@mozilla.org/browser/sessionstore;1"].
getService(Components.interfaces.nsISessionStore);
if (!ss.canRestoreLastSession)
document.getElementById("sessionRestoreContainer").hidden = true;
}
}
/**
* Handle command events bubbling up from error page content
*/
@ -2672,6 +2685,15 @@ function BrowserOnClick(event) {
);
}
}
else if (/^about:home$/i.test(errorDoc.documentURI)) {
if (ot == errorDoc.getElementById("restorePreviousSession")) {
let ss = Cc["@mozilla.org/browser/sessionstore;1"].
getService(Ci.nsISessionStore);
if (ss.canRestoreLastSession)
ss.restoreLastSession();
errorDoc.getElementById("sessionRestoreContainer").hidden = true;
}
}
}
/**
@ -4637,6 +4659,9 @@ var TabsProgressListener = {
aBrowser.removeEventListener("click", BrowserOnClick, false);
aBrowser.removeEventListener("pagehide", arguments.callee, true);
}, true);
// We also want to make changes to page UI for unprivileged about pages.
BrowserOnAboutPageLoad(aWebProgress.DOMWindow.document);
}
},

View File

@ -20,6 +20,8 @@ browser.jar:
* content/browser/aboutHome.xhtml (content/aboutHome.xhtml)
* content/browser/aboutHome.js (content/aboutHome.js)
* content/browser/aboutHome.css (content/aboutHome.css)
content/browser/aboutHome-restore-icon.png (content/aboutHome-restore-icon.png)
content/browser/aboutHome-restore-icon-rtl.png (content/aboutHome-restore-icon-rtl.png)
content/browser/aboutRobots-icon.png (content/aboutRobots-icon.png)
content/browser/aboutRobots-widget-left.png (content/aboutRobots-widget-left.png)
* content/browser/browser.css (content/browser.css)