Bug 563723 - Add an about:home page that mimics current start page. r=gavin,mano,dietrich a=blocking

This commit is contained in:
Marco Bonardo 2010-08-26 12:19:37 +02:00
parent 327c3cd911
commit 4ab88aa150
13 changed files with 433 additions and 29 deletions

View File

@ -0,0 +1,109 @@
%if 0
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License
* Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS"
* basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is aboutHome.xhtml.
*
* The Initial Developer of the Original Code is the Mozilla Foundation.
* Portions created by the Initial Developer are Copyright (C) 2010
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Marco Bonardo <mak77@bonardo.net> (original author)
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
%endif
html {
font: message-box;
background: -moz-Field;
color: -moz-FieldText;
}
#topSection,
#bottomSection {
position: relative;
margin: 1em auto;
padding: 25px;
width: 560px;
}
#brandStart {
background: -moz-linear-gradient(top, #42607C, #1E4262 30%, #1E4262 80%, #143552 98%, #244665);
-moz-border-radius: 1%;
padding-bottom: 0.2em;
-moz-padding-start: 0.5em;
font-size: 250%;
font-weight: bold;
color: #688196;
margin-top: 18px;
margin-bottom: 6px;
}
#brandStart > span {
color: white;
}
#brandLogo {
position: absolute;
top: 0;
}
body[dir="ltr"] #brandLogo {
right: 0;
}
body[dir="rtl"] #brandLogo {
left: -15px;
}
#searchContainer {
border: 1px solid ThreeDShadow;
-moz-border-radius: 1%;
padding: 3em;
}
#searchEngineLinks {
font-size: 80%;
}
#searchEngineLinks > a {
-moz-margin-start: 1em;
}
body[dir="ltr"] #searchEngineLinks {
float: right;
}
body[dir="rtl"] #searchEngineLinks {
float: left;
}
#searchEngineLogo {
margin: 5px;
}
#searchText {
width: 100%;
}
#aboutMozilla {
text-align: center;
}

View File

@ -0,0 +1,114 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License
* Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS"
* basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is aboutHome.xhtml.
*
* The Initial Developer of the Original Code is the Mozilla Foundation.
* Portions created by the Initial Developer are Copyright (C) 2010
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Marco Bonardo <mak77@bonardo.net> (original author)
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
// If a definition requires additional params, check that the final search url
// is handled correctly by the engine.
const SEARCH_ENGINES = {
"Google": {
image: "data:image/png;base64,i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KIJOPQSeVH+CDuZ2E3BIVmNkBB5agTF0NYV00y7jdMji0XqxvNljAzmEPASrQ0Vwhk41tPZiC6l3OjmNXYeYujfo3nF3v/fe/+le5hX5HyOTzv1Of88bnXelq0q8C9NRHMcpFrHd3gPTD0qV17uisWeDqE269gyguU88pcrRDowNXrqYTt1/xkQwXi8mZ2Q/TO9vDNa2FVkJLUPocDsYDoe1lB6EURzZ4RrDThHi0RF7mRh+bFGirCEYCJnMLpzUase5XI2aZxhjKM6wS64YJlDZqWxAPEq6ztjFm01KEzGdTxGirgoNFpRfrU7IEg8IiQFoqRlmqYp0p4VGDEO8zB1sYoLyKJlFVCdxjotwntNpISJqYfjKMQKi1fDVvJlqg2G6gWmh98l8iuRoWL1O7Bc53b2TJoSFc88xquwKqig8SGyDFvxRMGyriEdDUF140+DR9HN6hGHOBJIsjinLpvHoV84EIPGCL/ClAzOiojzfKeejz9WX3H6ru98Td6GWaqOi3lbBQQsTlyzzOU1ajjimTgpUkxRDN7Uvtl1kmTGMgT5+28BcAAC/SBSJBl7mWS1kkwRVnpWvs8n1HP6nMswFQmJyp71+DK4mgZ0ssEarFsiyQe0sg9V03acnG2luClgcQx+DKaOyTwTjAUNiS5OKWFGwZbGYw5GsiqKYNI6erp8XTo7TGigAToecVSofjvrEzMuyPBIe9xvXux2MvXCZZroQhNU6a7/mJ5VsK87l+FaD2TLpTvTTbTbj7bb13PiJZ0zAT+u6PtH9nhuKxD270s0hGAfSBOCgaJLHxDrlffcQzOoXSKyYjksOwdDWOLcG2H5i8zf27La6kVLrqwAAAABJRU5ErkJggg=="
, params: "source=hp"
, links: {
advanced: "http://www.google.com/advanced_search"
, preferences: "http://www.google.com/preferences"
}
}
, "Яндекс":
{
image: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGQAAAArCAMAAAC5Mt3fAAABnlBMVEX/////AAD/AwP/Bgb/CQn/DAz/Dw//EhL/FRX/GBj/Gxv/Hh7/ISH/JCT/Jyf/MDD/MzP/Pz//Q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v++srCmjz4VZL0595bdfFpRwOSy2QymdW97lOQDZEFKEqSFmHdISkodsul93C/KvlKeDIShkPmYDpE8rDrVcIOWfDybjlLJTc30XjD7MD5ujmJIEswESKFSIcs7AK3/HoDzDQxvjCzj+snPjJcBUiGyN9QmHvoeZ7nefNuuBZxe6+3OdJ12Kz9QqvV1QvlRIjswGLtD2RhbRi4I0l9NB2uE2Z2rOU+GYdVhci2q1G1iJZhp9cN13yDcbHD7KWLLZEZf3kGyDpsNyAjwLT8PPMNyEdm9knrHe/5JT5A7gP9UUQrUO6XtALVvohx7oBZx6WWSBJWpPodf7sBGXO1fQa/2NTG22Z2vHWBvOvOogDp2YXiQBTRBlR+lIaAYn0qX7WZdX7fEukpuXkeCQ6MLFC4GkVSwJykNWBjoBZ53cxOtTxPbm9B0fM8/9AqPpB0uQSwPDfvlSdCRB5Uk9JQBagszS3mC+E+PNTVEslRFwVJGqsEj7M1SBrISRrdCVovS5KOmrV9Fp7E7ZKkKkyGF4lmiIYeAVD6vd+/SKwEBbN6VdLgll9y0k99+cm5vNytxQ2BfspMXb/Wvd9LY5nfJpLPcDPbB/lv439BspTHg+9XKv417hniH6z+4JNllI0iAAAAAElFTkSuQmCC"
}
};
let gSearchEngine;
function onLoad(event)
{
setupSearchEngine();
document.getElementById("searchText").focus();
}
function onSearchSubmit(aEvent) {
let searchTerms = document.getElementById("searchText").value;
if (gSearchEngine && searchTerms.length > 0) {
const SEARCH_TOKENS = {
"_searchTerms_": encodeURIComponent(searchTerms)
}
let url = gSearchEngine.searchUrl;
for (let key in SEARCH_TOKENS) {
url = url.replace(key, SEARCH_TOKENS[key]);
}
window.location.href = url;
}
aEvent.preventDefault();
}
function setupSearchEngine() {
gSearchEngine = JSON.parse(localStorage["search-engine"]);
// Look for extended information, like logo and links.
let searchEngineInfo = SEARCH_ENGINES[gSearchEngine.name];
if (searchEngineInfo) {
for (let prop in searchEngineInfo)
gSearchEngine[prop] = searchEngineInfo[prop];
}
// Enqueue additional params if required by the engine definition.
if (gSearchEngine.params)
gSearchEngine.searchUrl += "&" + gSearchEngine.params;
// Add search engine logo.
if (gSearchEngine.image)
document.getElementById("searchEngineLogo").src = gSearchEngine.image;
if (gSearchEngine.links) {
// Add search engine links.
if (gSearchEngine.links.advanced) {
let advancedLink = document.getElementById("searchEngineAdvancedLink");
advancedLink.setAttribute("href", gSearchEngine.links.advanced);
advancedLink.hidden = false;
}
if (gSearchEngine.links.preferences) {
let prefsLink = document.getElementById("searchEngineAdvancedPreferences");
prefsLink.setAttribute("href", gSearchEngine.links.preferences);
prefsLink.hidden = false;
}
}
}

View File

@ -0,0 +1,94 @@
<?xml version="1.0" encoding="UTF-8"?>
# ***** BEGIN LICENSE BLOCK *****
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
#
# The contents of this file are subject to the Mozilla Public License
# Version
# 1.1 (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
# http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS"
# basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
# for the specific language governing rights and limitations under the
# License.
#
# The Original Code is aboutHome.xhtml.
#
# The Initial Developer of the Original Code is the Mozilla Foundation.
# Portions created by the Initial Developer are Copyright (C) 2010
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
# Marco Bonardo <mak77@bonardo.net> (original author)
#
# Alternatively, the contents of this file may be used under the terms of
# either the GNU General Public License Version 2 or later (the "GPL"), or
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
# in which case the provisions of the GPL or the LGPL are applicable instead
# of those above. If you wish to allow use of your version of this file only
# under the terms of either the GPL or the LGPL, and not to allow others to
# use your version of this file under the terms of the MPL, indicate your
# decision by deleting the provisions above and replace them with the notice
# and other provisions required by the GPL or the LGPL. If you do not delete
# the provisions above, a recipient may use your version of this file under
# the terms of any one of the MPL, the GPL or the LGPL.
#
# ***** END LICENSE BLOCK *****
<!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 % aboutHomeDTD SYSTEM "chrome://browser/locale/aboutHome.dtd">
%aboutHomeDTD;
]>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>&abouthome.pageTitle;</title>
<link rel="icon" type="image/png" id="favicon"
href="chrome://branding/content/icon16.png"/>
<link rel="stylesheet" type="text/css" media="all"
href="chrome://browser/content/aboutHome.css"/>
<script type="text/javascript;version=1.8"
src="chrome://browser/content/aboutHome.js"/>
</head>
<body dir="&locale.dir;" onload="onLoad(event)">
<div id="pageContainer">
<div id="topSection">
<img id="brandLogo" src="chrome://branding/content/icon128.png"
title="&abouthome.brandLogo.title;"/>
<div id="brandStart">
&abouthome.brandStart;
</div>
<div id ="searchContainer">
<img id="searchEngineLogo" title="&abouthome.searchEngineLogo.title;"/>
<form name="searchForm" onsubmit="onSearchSubmit(event)">
<input type="text" name="searchText" value="" id="searchText" maxLength="256"/>
<br/>
<input type="submit" value="&abouthome.searchEngineButton.label;"/>
<span id="searchEngineLinks">
<a hidden="true" id="searchEngineAdvancedLink">&abouthome.searchEngineLinks.advanced;</a>
<a hidden="true" id="searchEngineAdvancedPreferences">&abouthome.searchEngineLinks.preferences;</a>
</span>
</form>
</div>
</div>
<div id="bottomSection">
<div id="aboutMozilla">
<a href="http://www.mozilla.com/about/">&abouthome.aboutMozilla;</a>
</div>
</div>
</div>
</body>
</html>

View File

@ -3070,15 +3070,16 @@ const DOMLinkHandler = {
break;
// Verify that the load of this icon is legal.
// error pages can load their favicon, to be on the safe side,
// only allow chrome:// favicons
const aboutNeterr = /^about:neterror\?/;
const aboutBlocked = /^about:blocked\?/;
const aboutCert = /^about:certerror\?/;
if (!(aboutNeterr.test(targetDoc.documentURI) ||
aboutBlocked.test(targetDoc.documentURI) ||
aboutCert.test(targetDoc.documentURI)) ||
!uri.schemeIs("chrome")) {
// Some error or special pages can load their favicon.
// To be on the safe side, only allow chrome:// favicons.
var isAllowedPage = [
/^about:neterror\?/,
/^about:blocked\?/,
/^about:certerror\?/,
/^about:home$/,
].some(function (re) re.test(targetDoc.documentURI));
if (!isAllowedPage || !uri.schemeIs("chrome")) {
var ssm = Cc["@mozilla.org/scriptsecuritymanager;1"].
getService(Ci.nsIScriptSecurityManager);
try {

View File

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

View File

@ -1,7 +1,9 @@
browser.jar:
% content branding %content/branding/
% content branding %content/branding/ contentaccessible=yes
content/branding/about.png (about.png)
content/branding/aboutCredits.png (aboutCredits.png)
content/branding/aboutFooter.png (aboutFooter.png)
content/branding/icon48.png (icon48.png)
content/branding/icon64.png (icon64.png)
content/branding/icon128.png (../mozicon128.png)
content/branding/icon16.png (../default16.png)

View File

@ -1,7 +1,9 @@
browser.jar:
% content branding %content/branding/
% content branding %content/branding/ contentaccessible=yes
content/branding/about.png (about.png)
content/branding/aboutCredits.png (aboutCredits.png)
content/branding/aboutFooter.png (aboutFooter.png)
content/branding/icon48.png (icon48.png)
content/branding/icon64.png (icon64.png)
content/branding/icon128.png (../mozicon128.png)
content/branding/icon16.png (../default16.png)

View File

@ -100,6 +100,9 @@ static RedirEntry kRedirMap[] = {
{ "sync-tabs", "chrome://browser/content/aboutSyncTabs.xul",
nsIAboutModule::ALLOW_SCRIPT },
#endif
{ "home", "chrome://browser/content/aboutHome.xhtml",
nsIAboutModule::URI_SAFE_FOR_UNTRUSTED_CONTENT |
nsIAboutModule::ALLOW_SCRIPT },
};
static const int kRedirTotal = NS_ARRAY_LENGTH(kRedirMap);

View File

@ -205,6 +205,7 @@ static const mozilla::Module::ContractIDEntry kBrowserContracts[] = {
#ifdef MOZ_SERVICES_SYNC
{ NS_ABOUT_MODULE_CONTRACTID_PREFIX "sync-tabs", &kNS_BROWSER_ABOUT_REDIRECTOR_CID },
#endif
{ NS_ABOUT_MODULE_CONTRACTID_PREFIX "home", &kNS_BROWSER_ABOUT_REDIRECTOR_CID },
#ifndef WINCE
{ NS_PROFILEMIGRATOR_CONTRACTID, &kNS_FIREFOX_PROFILEMIGRATOR_CID },
#if defined(XP_WIN) && !defined(__MINGW32__)

View File

@ -37,6 +37,7 @@
# ***** END LICENSE BLOCK *****
Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
Components.utils.import("resource://gre/modules/Services.jsm");
const nsISupports = Components.interfaces.nsISupports;
@ -65,6 +66,7 @@ const nsICategoryManager = Components.interfaces.nsICategoryManager;
const nsIWebNavigationInfo = Components.interfaces.nsIWebNavigationInfo;
const nsIBrowserSearchService = Components.interfaces.nsIBrowserSearchService;
const nsICommandLineValidator = Components.interfaces.nsICommandLineValidator;
const nsIXULAppInfo = Components.interfaces.nsIXULAppInfo;
const NS_BINDING_ABORTED = Components.results.NS_BINDING_ABORTED;
const NS_ERROR_WONT_HANDLE_CONTENT = 0x805d0001;
@ -116,12 +118,15 @@ function resolveURIInternal(aCmdLine, aArgument) {
const OVERRIDE_NONE = 0;
const OVERRIDE_NEW_PROFILE = 1;
const OVERRIDE_NEW_MSTONE = 2;
const OVERRIDE_NEW_BUILD_ID = 3;
/**
* Determines whether a home page override is needed.
* Returns:
* OVERRIDE_NEW_PROFILE if this is the first run with a new profile.
* OVERRIDE_NEW_MSTONE if this is the first run with a build with a different
* Gecko milestone (i.e. right after an upgrade).
* OVERRIDE_NEW_BUILD_ID if this is the first run with a new build ID of the
* same Gecko milestone (i.e. after a nightly upgrade).
* OVERRIDE_NONE otherwise.
*/
function needHomepageOverride(prefb) {
@ -136,6 +141,14 @@ function needHomepageOverride(prefb) {
var mstone = Components.classes["@mozilla.org/network/protocol;1?name=http"]
.getService(nsIHttpProtocolHandler).misc;
var savedBuildID = null;
try {
savedBuildID = prefb.getCharPref("browser.startup.homepage_override.buildID");
} catch (e) {}
var buildID = Components.classes["@mozilla.org/xre/app-info;1"]
.getService(nsIXULAppInfo).platformBuildID;
if (mstone != savedmstone) {
// Bug 462254. Previous releases had a default pref to suppress the EULA
// agreement if the platform's installer had already shown one. Now with
@ -145,9 +158,15 @@ function needHomepageOverride(prefb) {
prefb.setBoolPref("browser.rights.3.shown", true);
prefb.setCharPref("browser.startup.homepage_override.mstone", mstone);
prefb.setCharPref("browser.startup.homepage_override.buildID", buildID);
return (savedmstone ? OVERRIDE_NEW_MSTONE : OVERRIDE_NEW_PROFILE);
}
if (buildID != savedBuildID) {
prefb.setCharPref("browser.startup.homepage_override.buildID", buildID);
return OVERRIDE_NEW_BUILD_ID;
}
return OVERRIDE_NONE;
}
@ -562,24 +581,31 @@ nsBrowserContentHandler.prototype = {
var overridePage = "";
var haveUpdateSession = false;
try {
switch (needHomepageOverride(prefb)) {
case OVERRIDE_NEW_PROFILE:
// New profile
overridePage = formatter.formatURLPref("startup.homepage_welcome_url");
break;
case OVERRIDE_NEW_MSTONE:
// Existing profile, new build
copyPrefOverride();
let override = needHomepageOverride(prefb);
Components.utils.reportError("OVERRIDE: " + override);
if (override != OVERRIDE_NONE) {
// Setup the default search engine to about:home page.
AboutHomeUtils.loadDefaultSearchEngine();
// Check whether we have a session to restore. If we do, we assume
// that this is an "update" session.
var ss = Components.classes["@mozilla.org/browser/sessionstartup;1"]
.getService(Components.interfaces.nsISessionStartup);
haveUpdateSession = ss.doRestore();
overridePage = formatter.formatURLPref("startup.homepage_override_url");
if (prefb.prefHasUserValue("app.update.postupdate"))
overridePage = getPostUpdateOverridePage(overridePage);
break;
switch (override) {
case OVERRIDE_NEW_PROFILE:
// New profile.
overridePage = formatter.formatURLPref("startup.homepage_welcome_url");
break;
case OVERRIDE_NEW_MSTONE:
// Existing profile, new milestone build.
copyPrefOverride();
// Check whether we have a session to restore. If we do, we assume
// that this is an "update" session.
var ss = Components.classes["@mozilla.org/browser/sessionstartup;1"]
.getService(Components.interfaces.nsISessionStartup);
haveUpdateSession = ss.doRestore();
overridePage = formatter.formatURLPref("startup.homepage_override_url");
if (prefb.prefHasUserValue("app.update.postupdate"))
overridePage = getPostUpdateOverridePage(overridePage);
break;
}
}
} catch (ex) {}
@ -856,5 +882,31 @@ nsDefaultCommandLineHandler.prototype = {
helpInfo : "",
};
let AboutHomeUtils = {
get _storage() {
let aboutHomeURI = Services.io.newURI("moz-safe-about:home", null, null);
let principal = Components.classes["@mozilla.org/scriptsecuritymanager;1"].
getService(Components.interfaces.nsIScriptSecurityManager).
getCodebasePrincipal(aboutHomeURI);
let dsm = Components.classes["@mozilla.org/dom/storagemanager;1"].
getService(Components.interfaces.nsIDOMStorageManager);
return dsm.getLocalStorageForPrincipal(principal, "");
},
loadDefaultSearchEngine: function AHU_loadDefaultSearchEngine()
{
// TODO: should use originalDefaultEngine once available, see bug 587691.
let defaultEngine = Services.search.defaultEngine;
let submission = defaultEngine.getSubmission("_searchTerms_");
if (submission.postData)
throw new Error("Home page does not support POST search engines.");
let engine = {
name: defaultEngine.name
, searchUrl: submission.uri.spec
}
this._storage.setItem("search-engine", JSON.stringify(engine));
}
};
var components = [nsBrowserContentHandler, nsDefaultCommandLineHandler];
var NSGetFactory = XPCOMUtils.generateNSGetFactory(components);

View File

@ -0,0 +1,20 @@
<!ENTITY % brandDTD
SYSTEM "chrome://branding/locale/brand.dtd">
%brandDTD;
<!-- These strings are used in the about:home page -->
<!ENTITY abouthome.pageTitle "&brandFullName; Start Page">
<!ENTITY abouthome.brandLogo.title "&brandFullName; logo">
<!-- LOCALIZATION NOTE (brandStart): brandShortName must be in a <span/> -->
<!ENTITY abouthome.brandStart "<span>&brandShortName;</span> Start">
<!ENTITY abouthome.searchEngineLogo.title "Search engine logo">
<!ENTITY abouthome.searchEngineButton.label "Search">
<!ENTITY abouthome.searchEngineLinks.advanced "Advanced Search">
<!ENTITY abouthome.searchEngineLinks.preferences "Preferences">
<!ENTITY abouthome.aboutMozilla "About Mozilla">

View File

@ -6,6 +6,7 @@
locale/browser/aboutDialog.dtd (%chrome/browser/aboutDialog.dtd)
locale/browser/aboutPrivateBrowsing.dtd (%chrome/browser/aboutPrivateBrowsing.dtd)
locale/browser/aboutRobots.dtd (%chrome/browser/aboutRobots.dtd)
locale/browser/aboutHome.dtd (%chrome/browser/aboutHome.dtd)
locale/browser/aboutSessionRestore.dtd (%chrome/browser/aboutSessionRestore.dtd)
#ifdef MOZ_SERVICES_SYNC
locale/browser/aboutSyncTabs.dtd (%chrome/browser/aboutSyncTabs.dtd)

View File

@ -1,7 +1,9 @@
browser.jar:
% content branding %content/branding/
% content branding %content/branding/ contentaccessible=yes
content/branding/about.png (about.png)
content/branding/aboutCredits.png (aboutCredits.png)
content/branding/aboutFooter.png (aboutFooter.png)
content/branding/icon48.png (icon48.png)
content/branding/icon64.png (icon64.png)
content/branding/icon128.png (../mozicon128.png)
content/branding/icon16.png (../default16.png)