gecko/mobile/android/chrome/content/aboutHome.xhtml

511 lines
18 KiB
HTML

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd" [
<!ENTITY % brandDTD SYSTEM "chrome://branding/locale/brand.dtd" >
%brandDTD;
<!ENTITY % globalDTD SYSTEM "chrome://global/locale/global.dtd" >
%globalDTD;
<!ENTITY % preferenceDTD SYSTEM "chrome://browser/locale/preferences.dtd" >
%preferenceDTD;
<!ENTITY % aboutDTD SYSTEM "chrome://browser/locale/aboutHome.dtd" >
%aboutDTD;
]>
<!-- ***** 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 Mozilla Communicator client code, released
- March 31, 1998.
-
- The Initial Developer of the Original Code is
- Netscape Communications Corporation.
- Portions created by the Initial Developer are Copyright (C) 1998-1999
- the Initial Developer. All Rights Reserved.
-
- Contributor(s):
- Mark Finkle <mfinkle@mozilla.com>
-
- 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 ***** -->
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>&homepage.default;</title>
<meta name="viewport" content="width=480; initial-scale=.6667; user-scalable=0" />
<link rel="icon" type="image/png" href="chrome://branding/content/favicon32.png" />
<link rel="stylesheet" href="chrome://browser/skin/aboutHome.css" type="text/css"/>
</head>
<body dir="&locale.dir;" onload="init();" onunload="uninit();">
<div id="wrapper">
<div id="header"><div id="logo"><img src="chrome://branding/content/logo.png"/></div>&aboutHome.header;</div>
<div id="content">
<div id="recentTabs" class="section-box">
<h1>&aboutHome.recentTabs;</h1>
<div id="loadingTabs" class="loading">
<img src="chrome://browser/skin/images/throbber.png"/>
</div>
</div>
<div id="remoteTabs" class="section-row" onclick="openRemoteTabs();" role="button">
<div>
<img class="favicon" src="chrome://browser/skin/images/remotetabs-32.png"/>
<div>&aboutHome.remoteTabs;</div>
</div>
</div>
<div id="newAddons" class="section-row" onclick="goToAddons(' ');" role="button">
<div>
<img class="favicon" src="chrome://browser/skin/images/addons-32.png"/>
<div>&aboutHome.recommendedAddons2;</div>
</div>
</div>
<div id="newAddonsList" class="section-box" style="display: none;">
</div>
<div id="locale" class="section-row" style="display: none;" onclick="openLocalePicker();" role="button">
<div>&aboutHome.getLocale;</div>
</div>
<div id="footer-wrapper">
<span id="feedback" style="width: &aboutHome.footerWidth;" class="section-row" pref="app.feedbackURL" onclick="openLink(this);" role="button">&aboutHome.giveFeedback;</span
><span id="support" style="width: &aboutHome.footerWidth;" class="section-row" pref="app.support.baseURL" onclick="openLink(this);" role="button">&aboutHome.getHelp;</span>
</div>
<div id="sync-setup">
<a id="syncSetupSync" href="#" onclick="openSetupSyncWizard();">&aboutHome.setupSync;</a>
<a id="syncPairDevice" href="#" onclick="openPairDeviceWizard();">&aboutHome.syncPairDevice;</a>
</div>
</div>
</div>
<!-- l10n hack -->
<div style="display: none">
<span id="text-openalltabs">&aboutHome.openAllTabs;</span>
<span id="text-notabs">&aboutHome.noTabs;</span>
<span id="text-noaddons">&aboutHome.noAddons;</span>
</div>
<!-- Lightbox -->
<div id="lightbox">
<div id="lightbox-background"></div>
<div id="lightbox-wrapper">
<div id="lightbox-container">
<img id="lightbox-logo" src="chrome://browser/skin/images/aurora-lightbox-logo.png"/>
<div id="lightbox-message">
<p class="title">&aboutHome.getInBeforeBeta;</p>
<p class="message">&aboutHome.tryAurora;</p>
</div>
<a id="lightbox-link">
<div id="lightbox-button">
<p class="title">&aboutHome.downloadAurora;</p>
<p class="sub-title">&aboutHome.forAndroid;</p>
</div>
</a>
<img id="lightbox-close" src="chrome://browser/skin/images/aurora-lightbox-close.png" alt="Aurora Close"/>
</div>
</div>
</div>
<script type="application/javascript;version=1.8"><![CDATA[
let Ci = Components.interfaces, Cc = Components.classes, Cu = Components.utils;
let gChromeWin = null;
Cu.import("resource://gre/modules/NetUtil.jsm");
function openLink(aElement) {
try {
let formatter = Cc["@mozilla.org/toolkit/URLFormatterService;1"].getService(Ci.nsIURLFormatter);
let url = formatter.formatURLPref(aElement.getAttribute("pref"));
openTabs([url]);
} catch (ex) {}
}
function getChromeWin() {
if (!gChromeWin) {
gChromeWin = window
.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIWebNavigation)
.QueryInterface(Ci.nsIDocShellTreeItem)
.rootTreeItem
.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIDOMWindow)
.QueryInterface(Ci.nsIDOMChromeWindow);
}
return gChromeWin;
}
function openLocalePicker() {
let win = getChromeWin();
win.BrowserUI.showPanel("prefs-container");
win.document.getElementById("prefs-uilanguage-button").click();
}
function init() {
initTabs();
initAddons();
initSetupSync();
let prefs = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefService).QueryInterface(Ci.nsIPrefBranch2);
if (prefs.getBoolPref("browser.firstrun.show.uidiscovery")) {
startDiscovery();
prefs.setBoolPref("browser.firstrun.show.uidiscovery", false);
document.getElementById("locale").style.display = "block";
} else {
endDiscovery();
}
initLightbox();
}
function uninit() {
uninitAddons();
uninitSetupSync();
}
function _readFile(aFile, aCallback) {
let channel = NetUtil.newChannel(aFile);
channel.contentType = "application/json";
NetUtil.asyncFetch(channel, function(aStream, aResult) {
if (!Components.isSuccessCode(aResult)) {
Cu.reportError("AboutHome: Could not read from " + aFile.leafName);
aCallback(null);
return;
}
let fileSize = aStream.available();
let cvstream = Cc["@mozilla.org/intl/converter-input-stream;1"].createInstance(Ci.nsIConverterInputStream);
cvstream.init(aStream, "UTF-8", fileSize, Ci.nsIConverterInputStream.DEFAULT_REPLACEMENT_CHARACTER);
let content = {};
cvstream.readString(fileSize, content);
cvstream.close();
aStream.close();
aCallback(content.value.replace(/\r\n?/g, "\n"));
});
}
function openTabs(aURLs) {
let BrowserUI = getChromeWin().BrowserUI;
let owner = getChromeWin().Browser.selectedTab;
for (let i=0; i < aURLs.length; i++) {
BrowserUI.newTab(aURLs[i], owner);
}
}
function initTabs() {
function noRecentTabs() {
let placeHolder = document.getElementById("loadingTabs");
placeHolder.innerHTML = "<div class='no-items'>" + document.getElementById("text-notabs").textContent + "</div>";
}
let dirService = Cc["@mozilla.org/file/directory_service;1"].getService(Ci.nsIProperties);
let session = dirService.get("ProfD", Ci.nsILocalFile);
session.append("sessionstore.bak");
if (!session.exists()) {
noRecentTabs();
return;
}
_readFile(session, function(aContent) {
let data = JSON.parse(aContent);
if (!data || data.windows.length == 0) {
noRecentTabs();
return;
}
let chromeWin = getChromeWin();
let allPageURLs = [];
let list = document.getElementById("recentTabs");
let tabs = data.windows[0].tabs;
for (let i=0; i<tabs.length; i++) {
let tabData = tabs[i];
let tabEntry = tabData.entries[tabData.index - 1];
let url = tabEntry.url;
if (url.indexOf("about:") == 0)
continue;
let title = tabEntry.title;
if (!title)
continue;
let uri = chromeWin.Util.makeURI(url);
let favicon = chromeWin.gFaviconService.getFaviconImageForPage(uri).spec;
let outer = document.createElement("a");
outer.setAttribute("role", "button");
outer.setAttribute("href", url);
allPageURLs.push(url);
let img = document.createElement("img");
img.className = "favicon";
img.setAttribute("src", favicon);
outer.appendChild(img);
let inner = document.createElement("div");
inner.className = "inner";
let titlePart = document.createElement("div");
titlePart.textContent = title;
titlePart.className = "title";
inner.appendChild(titlePart);
outer.appendChild(inner);
list.appendChild(outer);
}
if (allPageURLs.length > 0) {
let loading = document.getElementById("loadingTabs");
loading.parentNode.removeChild(loading);
if (allPageURLs.length > 1) {
let outer = document.createElement("div");
outer.className = "openall";
outer.textContent = document.getElementById("text-openalltabs").textContent;
outer.setAttribute("role", "button");
outer.addEventListener("click", function() {
openTabs(allPageURLs);
}, false);
list.appendChild(outer);
}
} else {
noRecentTabs();
}
});
}
function openRemoteTabs() {
getChromeWin().CommandUpdater.doCommand("cmd_remoteTabs");
}
function goToAddons(aSearchString) {
let chromeWin = getChromeWin();
let BrowserUI = chromeWin.BrowserUI;
BrowserUI.showPanel("addons-container");
if (aSearchString) {
// ExtensionsView initialization is delayed, so need to delay triggering
// the search as well
setTimeout(function () {
// do the search
chromeWin.ExtensionsView.doSearch(aSearchString);
}, 0);
}
}
var RecommendedAddons = {
_getFile: function() {
let dirService = Cc["@mozilla.org/file/directory_service;1"].getService(Ci.nsIProperties);
let file = dirService.get("ProfD", Ci.nsILocalFile);
file.append("recommended-addons.json");
return file;
},
_loadAddons: function(aAddons) {
if (aAddons.length == 0)
return;
// Clear all content before filling the addons
let list = document.getElementById("newAddonsList");
while (list.firstElementChild)
list.removeChild(list.firstElementChild);
for (let i=0; i<aAddons.length; i++) {
let addon = aAddons[i];
let outer = document.createElement("div");
outer.setAttribute("role", "button");
outer.setAttribute("addonID", addon.id);
let addonName = aAddons[i].name;
outer.addEventListener("click", function() {
goToAddons(addonName);
}, false)
let img = document.createElement("img");
img.className = "favicon";
img.setAttribute("src", addon.iconURL);
outer.appendChild(img);
let inner = document.createElement("div");
inner.className = "inner";
let titlePart = document.createElement("span");
titlePart.textContent = addon.name;
titlePart.className = "title";
inner.appendChild(titlePart);
let versionPart = document.createElement("span");
versionPart.textContent = addon.version;
versionPart.className = "version";
inner.appendChild(versionPart);
outer.appendChild(inner);
list.appendChild(outer);
}
list.style.display = "block";
document.getElementById("newAddons").setAttribute("showlist", "true");
},
loadFromCache: function loadFromCache() {
let self = this;
let file = this._getFile();
if (file.exists()) {
_readFile(file, function(aContent) {
let json = JSON.parse(aContent);
if (!json || json.addons.length == 0) {
self._loadAddons([]);
return;
}
self._loadAddons(json.addons);
});
}
}
}
function updateAddons() {
RecommendedAddons.loadFromCache();
}
function initAddons() {
getChromeWin().Services.obs.addObserver(updateAddons, "recommended-addons-cache-updated", false);
updateAddons();
}
function uninitAddons() {
getChromeWin().Services.obs.removeObserver(updateAddons, "recommended-addons-cache-updated");
}
function startDiscovery() {
let win = getChromeWin();
// If a sidebar is completely open, just bail
let [leftWidth, rightWidth] = win.Browser.computeSidebarVisibility();
if (leftWidth == 1 || rightWidth == 1 || win.Util.isTablet()) {
endDiscovery();
return;
}
let doc = win.document;
let broadcaster = doc.getElementById("bcast_uidiscovery");
doc.addEventListener("animationend", endDiscovery, false);
doc.addEventListener("PanBegin", endDiscovery, false);
broadcaster.setAttribute("mode", "discovery");
}
function endDiscovery() {
let doc = getChromeWin().document;
let broadcaster = doc.getElementById("bcast_uidiscovery");
broadcaster.removeAttribute("mode");
doc.removeEventListener("animationend", endDiscovery, false);
doc.removeEventListener("PanBegin", endDiscovery, false);
}
function initSetupSync() {
let services = getChromeWin().Services;
if (services.prefs.prefHasUserValue("services.sync.username")) {
syncConnected();
} else {
syncDisconnected();
}
services.obs.addObserver(syncConnected, "weave:service:setup-complete", false);
services.obs.addObserver(syncDisconnected, "weave:service:start-over", false);
}
function uninitSetupSync() {
let services = getChromeWin().Services;
services.obs.removeObserver(syncConnected, "weave:service:setup-complete");
services.obs.removeObserver(syncDisconnected, "weave:service:start-over");
}
function syncConnected() {
document.getElementById("syncSetupSync").style.display = "none";
document.getElementById("syncPairDevice").style.display = "inline";
}
function syncDisconnected() {
document.getElementById("syncSetupSync").style.display = "inline";
document.getElementById("syncPairDevice").style.display = "none";
}
function openSetupSyncWizard() {
let chromeWin = getChromeWin();
chromeWin.WeaveGlue.open();
}
function openPairDeviceWizard() {
let chromeWin = getChromeWin();
chromeWin.SyncPairDevice.open();
}
function initLightbox() {
let prefs = getChromeWin().Services.prefs;
let channel = prefs.getCharPref("app.update.channel");
let startupCount = 0;
try {
startupCount = prefs.getIntPref("app.promo.aurora");
if(startupCount != 6)
prefs.setIntPref("app.promo.aurora", ++startupCount);
} catch(e) {
prefs.setIntPref("app.promo.aurora", 1);
}
// This should appear only on "beta" channel on the fifth launch.
if ((channel == "beta") && (startupCount == 5)) {
let close = document.getElementById("lightbox-close");
close.addEventListener("click", function() {
document.getElementById("lightbox").style.display = "none";
}, false);
let link = document.getElementById("lightbox-link");
link.addEventListener("click", function(event) {
event.preventDefault();
document.getElementById("lightbox").style.display = "none";
let BrowserUI = getChromeWin().BrowserUI;
let owner = getChromeWin().Browser.selectedTab;
let formatter = Cc["@mozilla.org/toolkit/URLFormatterService;1"].getService(Ci.nsIURLFormatter);
let linkUrl = formatter.formatURLPref("app.channelURL");
BrowserUI.newTab(linkUrl, owner);
}, false);
// Giving a chance for any page transitions to happen, if any, before displaying the lightbox
setTimeout(function() {
document.getElementById("lightbox").style.display = "block";
}, 300);
}
}
]]></script>
</body>
</html>