2007-06-05 04:51:15 +00:00
|
|
|
<?xml version="1.0"?>
|
|
|
|
|
|
|
|
# -*- Mode: HTML -*-
|
2012-05-21 11:12:37 +00:00
|
|
|
# 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/.
|
2007-06-05 04:51:15 +00:00
|
|
|
|
2010-12-16 17:53:24 +00:00
|
|
|
<!DOCTYPE bindings [
|
|
|
|
<!ENTITY % notificationDTD SYSTEM "chrome://global/locale/notification.dtd">
|
|
|
|
%notificationDTD;
|
2013-06-24 12:51:07 +00:00
|
|
|
<!ENTITY % browserDTD SYSTEM "chrome://browser/locale/browser.dtd">
|
|
|
|
%browserDTD;
|
2010-12-16 17:53:24 +00:00
|
|
|
]>
|
|
|
|
|
2010-04-09 17:45:25 +00:00
|
|
|
<bindings id="urlbarBindings" xmlns="http://www.mozilla.org/xbl"
|
2010-09-15 05:41:16 +00:00
|
|
|
xmlns:html="http://www.w3.org/1999/xhtml"
|
2010-04-09 17:45:25 +00:00
|
|
|
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
|
|
|
xmlns:xbl="http://www.mozilla.org/xbl">
|
2007-06-27 22:31:06 +00:00
|
|
|
|
|
|
|
<binding id="urlbar" extends="chrome://global/content/bindings/autocomplete.xml#autocomplete">
|
2010-09-15 05:41:16 +00:00
|
|
|
|
|
|
|
<content sizetopopup="pref">
|
2011-02-03 06:48:39 +00:00
|
|
|
<xul:hbox anonid="textbox-container"
|
|
|
|
class="autocomplete-textbox-container urlbar-textbox-container"
|
|
|
|
flex="1" xbl:inherits="focused">
|
2011-02-11 00:59:40 +00:00
|
|
|
<children includes="image|deck|stack|box">
|
|
|
|
<xul:image class="autocomplete-icon" allowevents="true"/>
|
|
|
|
</children>
|
2011-02-03 06:48:39 +00:00
|
|
|
<xul:hbox anonid="textbox-input-box"
|
|
|
|
class="textbox-input-box urlbar-input-box"
|
|
|
|
flex="1" xbl:inherits="tooltiptext=inputtooltiptext">
|
|
|
|
<children/>
|
|
|
|
<html:input anonid="input"
|
|
|
|
class="autocomplete-textbox urlbar-input textbox-input uri-element-right-align"
|
2011-04-23 01:36:24 +00:00
|
|
|
allowevents="true"
|
2012-03-04 14:57:45 +00:00
|
|
|
xbl:inherits="tooltiptext=inputtooltiptext,value,type,maxlength,disabled,size,readonly,placeholder,tabindex,accesskey"/>
|
2010-10-12 03:47:59 +00:00
|
|
|
</xul:hbox>
|
2011-02-03 06:48:39 +00:00
|
|
|
<children includes="hbox"/>
|
2010-10-12 03:47:59 +00:00
|
|
|
</xul:hbox>
|
2011-02-03 06:48:39 +00:00
|
|
|
<xul:dropmarker anonid="historydropmarker"
|
|
|
|
class="autocomplete-history-dropmarker urlbar-history-dropmarker"
|
|
|
|
allowevents="true"
|
|
|
|
xbl:inherits="open,enablehistory,parentfocused=focused"/>
|
|
|
|
<xul:popupset anonid="popupset"
|
|
|
|
class="autocomplete-result-popupset"/>
|
2010-09-15 05:41:16 +00:00
|
|
|
<children includes="toolbarbutton"/>
|
|
|
|
</content>
|
|
|
|
|
2007-08-04 08:35:28 +00:00
|
|
|
<implementation implements="nsIObserver, nsIDOMEventListener">
|
2007-06-27 22:31:06 +00:00
|
|
|
<constructor><![CDATA[
|
|
|
|
this._prefs = Components.classes["@mozilla.org/preferences-service;1"]
|
|
|
|
.getService(Components.interfaces.nsIPrefService)
|
2012-01-17 01:34:51 +00:00
|
|
|
.getBranch("browser.urlbar.");
|
2007-06-27 22:31:06 +00:00
|
|
|
|
|
|
|
this._prefs.addObserver("", this, false);
|
2007-07-03 17:40:40 +00:00
|
|
|
this.clickSelectsAll = this._prefs.getBoolPref("clickSelectsAll");
|
2007-08-04 08:35:28 +00:00
|
|
|
this.doubleClickSelectsAll = this._prefs.getBoolPref("doubleClickSelectsAll");
|
2007-07-03 17:40:40 +00:00
|
|
|
this.completeDefaultIndex = this._prefs.getBoolPref("autoFill");
|
2009-06-17 15:27:04 +00:00
|
|
|
this.timeout = this._prefs.getIntPref("delay");
|
2011-05-02 17:50:18 +00:00
|
|
|
this._formattingEnabled = this._prefs.getBoolPref("formatting.enabled");
|
2011-06-23 08:13:41 +00:00
|
|
|
this._mayTrimURLs = this._prefs.getBoolPref("trimURLs");
|
2007-06-27 22:31:06 +00:00
|
|
|
|
|
|
|
this.inputField.controllers.insertControllerAt(0, this._copyCutController);
|
2007-08-04 08:35:28 +00:00
|
|
|
this.inputField.addEventListener("mousedown", this, false);
|
2007-10-26 02:53:01 +00:00
|
|
|
this.inputField.addEventListener("mousemove", this, false);
|
|
|
|
this.inputField.addEventListener("mouseout", this, false);
|
2010-03-26 21:59:02 +00:00
|
|
|
this.inputField.addEventListener("overflow", this, false);
|
|
|
|
this.inputField.addEventListener("underflow", this, false);
|
2010-09-16 07:51:24 +00:00
|
|
|
|
|
|
|
const kXULNS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
|
|
|
|
var textBox = document.getAnonymousElementByAttribute(this,
|
|
|
|
"anonid", "textbox-input-box");
|
|
|
|
var cxmenu = document.getAnonymousElementByAttribute(textBox,
|
|
|
|
"anonid", "input-box-contextmenu");
|
2010-09-21 04:32:00 +00:00
|
|
|
var pasteAndGo;
|
|
|
|
cxmenu.addEventListener("popupshowing", function() {
|
|
|
|
if (!pasteAndGo)
|
|
|
|
return;
|
|
|
|
var controller = document.commandDispatcher.getControllerForCommand("cmd_paste");
|
2010-11-22 19:50:49 +00:00
|
|
|
var enabled = controller.isCommandEnabled("cmd_paste");
|
|
|
|
if (enabled)
|
|
|
|
pasteAndGo.removeAttribute("disabled");
|
|
|
|
else
|
|
|
|
pasteAndGo.setAttribute("disabled", "true");
|
2010-09-21 04:32:00 +00:00
|
|
|
}, false);
|
|
|
|
|
2010-09-16 07:51:24 +00:00
|
|
|
var insertLocation = cxmenu.firstChild;
|
|
|
|
while (insertLocation.nextSibling &&
|
|
|
|
insertLocation.getAttribute("cmd") != "cmd_paste")
|
|
|
|
insertLocation = insertLocation.nextSibling;
|
|
|
|
if (insertLocation) {
|
2010-09-21 04:32:00 +00:00
|
|
|
pasteAndGo = document.createElement("menuitem");
|
2010-09-16 07:51:24 +00:00
|
|
|
let label = Services.strings.createBundle("chrome://browser/locale/browser.properties").
|
|
|
|
GetStringFromName("pasteAndGo.label");
|
2010-09-21 04:32:00 +00:00
|
|
|
pasteAndGo.setAttribute("label", label);
|
|
|
|
pasteAndGo.setAttribute("anonid", "paste-and-go");
|
2010-10-26 22:35:44 +00:00
|
|
|
pasteAndGo.setAttribute("oncommand",
|
2010-11-05 19:56:03 +00:00
|
|
|
"gURLBar.select(); goDoCommand('cmd_paste'); gURLBar.handleCommand();");
|
2010-09-21 04:32:00 +00:00
|
|
|
cxmenu.insertBefore(pasteAndGo, insertLocation.nextSibling);
|
2010-09-16 07:51:24 +00:00
|
|
|
}
|
2007-06-27 22:31:06 +00:00
|
|
|
]]></constructor>
|
|
|
|
|
|
|
|
<destructor><![CDATA[
|
|
|
|
this._prefs.removeObserver("", this);
|
|
|
|
this._prefs = null;
|
|
|
|
this.inputField.controllers.removeController(this._copyCutController);
|
2007-08-04 08:35:28 +00:00
|
|
|
this.inputField.removeEventListener("mousedown", this, false);
|
2007-10-26 02:53:01 +00:00
|
|
|
this.inputField.removeEventListener("mousemove", this, false);
|
|
|
|
this.inputField.removeEventListener("mouseout", this, false);
|
2010-03-26 21:59:02 +00:00
|
|
|
this.inputField.removeEventListener("overflow", this, false);
|
|
|
|
this.inputField.removeEventListener("underflow", this, false);
|
2007-06-27 22:31:06 +00:00
|
|
|
]]></destructor>
|
|
|
|
|
2010-03-26 21:59:02 +00:00
|
|
|
<field name="_value"></field>
|
|
|
|
|
|
|
|
<!--
|
|
|
|
onBeforeValueGet is called by the base-binding's .value getter.
|
|
|
|
It can return an object with a "value" property, to override the
|
|
|
|
return value of the getter.
|
|
|
|
-->
|
|
|
|
<method name="onBeforeValueGet">
|
|
|
|
<body><![CDATA[
|
|
|
|
if (this.hasAttribute("actiontype"))
|
|
|
|
return {value: this._value};
|
|
|
|
return null;
|
|
|
|
]]></body>
|
|
|
|
</method>
|
|
|
|
|
|
|
|
<!--
|
|
|
|
onBeforeValueSet is called by the base-binding's .value setter.
|
|
|
|
It should return the value that the setter should use.
|
|
|
|
-->
|
|
|
|
<method name="onBeforeValueSet">
|
|
|
|
<parameter name="aValue"/>
|
|
|
|
<body><![CDATA[
|
|
|
|
this._value = aValue;
|
|
|
|
var returnValue = aValue;
|
|
|
|
var action = this._parseActionUrl(aValue);
|
|
|
|
if (action) {
|
|
|
|
returnValue = action.param;
|
|
|
|
this.setAttribute("actiontype", action.type);
|
|
|
|
} else {
|
|
|
|
this.removeAttribute("actiontype");
|
|
|
|
}
|
|
|
|
return returnValue;
|
|
|
|
]]></body>
|
|
|
|
</method>
|
|
|
|
|
2011-06-23 08:13:41 +00:00
|
|
|
<field name="_mayTrimURLs">true</field>
|
|
|
|
<method name="trimValue">
|
|
|
|
<parameter name="aURL"/>
|
|
|
|
<body><![CDATA[
|
2011-09-20 03:35:33 +00:00
|
|
|
// This method must not modify the given URL such that calling
|
|
|
|
// nsIURIFixup::createFixupURI with the result will produce a different URI.
|
2011-06-23 08:13:41 +00:00
|
|
|
return this._mayTrimURLs ? trimURL(aURL) : aURL;
|
|
|
|
]]></body>
|
|
|
|
</method>
|
|
|
|
|
2011-05-02 17:50:18 +00:00
|
|
|
<field name="_formattingEnabled">true</field>
|
|
|
|
<method name="formatValue">
|
|
|
|
<body><![CDATA[
|
2013-07-01 09:33:28 +00:00
|
|
|
if (!this._formattingEnabled || this.focused)
|
2011-05-02 17:50:18 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
let controller = this.editor.selectionController;
|
|
|
|
let selection = controller.getSelection(controller.SELECTION_URLSECONDARY);
|
|
|
|
selection.removeAllRanges();
|
|
|
|
|
|
|
|
let textNode = this.editor.rootElement.firstChild;
|
|
|
|
let value = textNode.textContent;
|
2011-06-23 08:13:41 +00:00
|
|
|
|
2011-10-08 08:32:22 +00:00
|
|
|
let protocol = value.match(/^[a-z\d.+\-]+:(?=[^\d])/);
|
2011-06-23 08:13:41 +00:00
|
|
|
if (protocol &&
|
|
|
|
["http:", "https:", "ftp:"].indexOf(protocol[0]) == -1)
|
|
|
|
return;
|
|
|
|
let matchedURL = value.match(/^((?:[a-z]+:\/\/)?(?:[^\/]+@)?)(.+?)(?::\d+)?(?:\/|$)/);
|
2011-05-02 17:50:18 +00:00
|
|
|
if (!matchedURL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
let [, preDomain, domain] = matchedURL;
|
|
|
|
let baseDomain = domain;
|
2011-06-25 07:41:31 +00:00
|
|
|
let subDomain = "";
|
|
|
|
// getBaseDomainFromHost doesn't recognize IPv6 literals in brackets as IPs (bug 667159)
|
|
|
|
if (domain[0] != "[") {
|
|
|
|
try {
|
|
|
|
baseDomain = Services.eTLD.getBaseDomainFromHost(domain);
|
2012-09-26 17:14:56 +00:00
|
|
|
if (!domain.endsWith(baseDomain)) {
|
2012-09-21 23:03:23 +00:00
|
|
|
// getBaseDomainFromHost converts its resultant to ACE.
|
|
|
|
let IDNService = Cc["@mozilla.org/network/idn-service;1"]
|
|
|
|
.getService(Ci.nsIIDNService);
|
|
|
|
baseDomain = IDNService.convertACEtoUTF8(baseDomain);
|
|
|
|
}
|
2011-06-25 07:41:31 +00:00
|
|
|
} catch (e) {}
|
|
|
|
}
|
|
|
|
if (baseDomain != domain) {
|
2012-09-21 23:03:23 +00:00
|
|
|
subDomain = domain.slice(0, -baseDomain.length);
|
2011-06-25 07:41:31 +00:00
|
|
|
}
|
2011-05-02 17:50:18 +00:00
|
|
|
|
2011-06-23 08:13:41 +00:00
|
|
|
let rangeLength = preDomain.length + subDomain.length;
|
|
|
|
if (rangeLength) {
|
|
|
|
let range = document.createRange();
|
|
|
|
range.setStart(textNode, 0);
|
|
|
|
range.setEnd(textNode, rangeLength);
|
|
|
|
selection.addRange(range);
|
|
|
|
}
|
2011-05-02 17:50:18 +00:00
|
|
|
|
|
|
|
let startRest = preDomain.length + domain.length;
|
|
|
|
if (startRest < value.length) {
|
2011-06-23 08:13:41 +00:00
|
|
|
let range = document.createRange();
|
2011-05-02 17:50:18 +00:00
|
|
|
range.setStart(textNode, startRest);
|
|
|
|
range.setEnd(textNode, value.length);
|
|
|
|
selection.addRange(range);
|
|
|
|
}
|
|
|
|
]]></body>
|
|
|
|
</method>
|
|
|
|
|
2011-05-12 21:38:40 +00:00
|
|
|
<method name="_clearFormatting">
|
|
|
|
<body><![CDATA[
|
|
|
|
if (!this._formattingEnabled)
|
|
|
|
return;
|
|
|
|
|
|
|
|
let controller = this.editor.selectionController;
|
|
|
|
let selection = controller.getSelection(controller.SELECTION_URLSECONDARY);
|
|
|
|
selection.removeAllRanges();
|
|
|
|
]]></body>
|
|
|
|
</method>
|
|
|
|
|
2008-09-25 11:33:51 +00:00
|
|
|
<method name="handleRevert">
|
|
|
|
<body><![CDATA[
|
|
|
|
var isScrolling = this.popupOpen;
|
|
|
|
|
|
|
|
gBrowser.userTypedValue = null;
|
|
|
|
|
|
|
|
// don't revert to last valid url unless page is NOT loading
|
|
|
|
// and user is NOT key-scrolling through autocomplete list
|
2008-10-25 13:15:53 +00:00
|
|
|
if (!XULBrowserWindow.isBusy && !isScrolling) {
|
2008-09-25 11:33:51 +00:00
|
|
|
URLBarSetURI();
|
|
|
|
|
|
|
|
// If the value isn't empty and the urlbar has focus, select the value.
|
|
|
|
if (this.value && this.hasAttribute("focused"))
|
|
|
|
this.select();
|
|
|
|
}
|
|
|
|
|
|
|
|
// tell widget to revert to last typed text only if the user
|
|
|
|
// was scrolling when they hit escape
|
|
|
|
return !isScrolling;
|
|
|
|
]]></body>
|
|
|
|
</method>
|
|
|
|
|
|
|
|
<method name="handleCommand">
|
|
|
|
<parameter name="aTriggeringEvent"/>
|
|
|
|
<body><![CDATA[
|
|
|
|
if (aTriggeringEvent instanceof MouseEvent && aTriggeringEvent.button == 2)
|
|
|
|
return; // Do nothing for right clicks
|
|
|
|
|
2010-07-16 05:05:47 +00:00
|
|
|
var url = this.value;
|
2011-05-31 21:33:46 +00:00
|
|
|
var mayInheritPrincipal = false;
|
2010-07-16 05:05:47 +00:00
|
|
|
var postData = null;
|
2008-09-25 11:33:51 +00:00
|
|
|
|
2010-03-26 21:59:02 +00:00
|
|
|
var action = this._parseActionUrl(url);
|
2013-06-25 01:26:22 +00:00
|
|
|
let lastLocationChange = gBrowser.selectedBrowser.lastLocationChange;
|
|
|
|
Task.spawn(function() {
|
|
|
|
let matchLastLocationChange = true;
|
|
|
|
if (action) {
|
|
|
|
url = action.param;
|
|
|
|
if (this.hasAttribute("actiontype")) {
|
|
|
|
if (action.type == "switchtab") {
|
|
|
|
this.handleRevert();
|
|
|
|
let prevTab = gBrowser.selectedTab;
|
|
|
|
if (switchToTabHavingURI(url) &&
|
|
|
|
isTabEmpty(prevTab))
|
|
|
|
gBrowser.removeTab(prevTab);
|
|
|
|
}
|
|
|
|
return;
|
2010-11-07 12:59:51 +00:00
|
|
|
}
|
2010-07-16 05:05:47 +00:00
|
|
|
}
|
2013-06-25 01:26:22 +00:00
|
|
|
else {
|
|
|
|
[url, postData, mayInheritPrincipal] = yield this._canonizeURL(aTriggeringEvent);
|
|
|
|
matchLastLocationChange = (lastLocationChange ==
|
|
|
|
gBrowser.selectedBrowser.lastLocationChange);
|
|
|
|
if (!url)
|
|
|
|
return;
|
|
|
|
}
|
2010-03-26 21:59:02 +00:00
|
|
|
|
2013-06-25 01:26:22 +00:00
|
|
|
this.value = url;
|
|
|
|
gBrowser.userTypedValue = url;
|
|
|
|
try {
|
|
|
|
addToUrlbarHistory(url);
|
|
|
|
} catch (ex) {
|
|
|
|
// Things may go wrong when adding url to session history,
|
|
|
|
// but don't let that interfere with the loading of the url.
|
|
|
|
Cu.reportError(ex);
|
|
|
|
}
|
2008-09-25 11:33:51 +00:00
|
|
|
|
2013-06-25 01:26:22 +00:00
|
|
|
function loadCurrent() {
|
|
|
|
let flags = Ci.nsIWebNavigation.LOAD_FLAGS_ALLOW_THIRD_PARTY_FIXUP;
|
|
|
|
// Pass LOAD_FLAGS_DISALLOW_INHERIT_OWNER to prevent any loads from
|
|
|
|
// inheriting the currently loaded document's principal, unless this
|
|
|
|
// URL is marked as safe to inherit (e.g. came from a bookmark
|
|
|
|
// keyword).
|
|
|
|
if (!mayInheritPrincipal)
|
|
|
|
flags |= Ci.nsIWebNavigation.LOAD_FLAGS_DISALLOW_INHERIT_OWNER;
|
|
|
|
// If the value wasn't typed, we know that we decoded the value as
|
|
|
|
// UTF-8 (see losslessDecodeURI)
|
|
|
|
if (!this.valueIsTyped)
|
|
|
|
flags |= Ci.nsIWebNavigation.LOAD_FLAGS_URI_IS_UTF8;
|
|
|
|
gBrowser.loadURIWithFlags(url, flags, null, null, postData);
|
|
|
|
}
|
2011-05-19 23:44:01 +00:00
|
|
|
|
2013-06-25 01:26:22 +00:00
|
|
|
// Focus the content area before triggering loads, since if the load
|
|
|
|
// occurs in a new tab, we want focus to be restored to the content
|
|
|
|
// area when the current tab is re-selected.
|
|
|
|
gBrowser.selectedBrowser.focus();
|
2011-07-20 20:21:55 +00:00
|
|
|
|
2013-06-25 01:26:22 +00:00
|
|
|
let isMouseEvent = aTriggeringEvent instanceof MouseEvent;
|
|
|
|
let altEnter = !isMouseEvent && aTriggeringEvent && aTriggeringEvent.altKey;
|
2010-11-07 13:30:26 +00:00
|
|
|
|
2013-06-25 01:26:22 +00:00
|
|
|
if (altEnter) {
|
|
|
|
// XXX This was added a long time ago, and I'm not sure why it is
|
|
|
|
// necessary. Alt+Enter's default action might cause a system beep,
|
|
|
|
// or something like that?
|
|
|
|
aTriggeringEvent.preventDefault();
|
|
|
|
aTriggeringEvent.stopPropagation();
|
|
|
|
}
|
2010-11-07 13:30:26 +00:00
|
|
|
|
2013-06-25 01:26:22 +00:00
|
|
|
// If the current tab is empty, ignore Alt+Enter (just reuse this tab)
|
|
|
|
altEnter = altEnter && !isTabEmpty(gBrowser.selectedTab);
|
2010-11-07 13:30:26 +00:00
|
|
|
|
2013-06-25 01:26:22 +00:00
|
|
|
if (isMouseEvent || altEnter) {
|
|
|
|
// Use the standard UI link behaviors for clicks or Alt+Enter
|
|
|
|
let where = "tab";
|
|
|
|
if (isMouseEvent)
|
|
|
|
where = whereToOpenLink(aTriggeringEvent, false, false);
|
2010-11-07 13:30:26 +00:00
|
|
|
|
2013-06-25 01:26:22 +00:00
|
|
|
if (where == "current") {
|
|
|
|
if (matchLastLocationChange) {
|
|
|
|
loadCurrent();
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
this.handleRevert();
|
|
|
|
let params = { allowThirdPartyFixup: true,
|
|
|
|
postData: postData,
|
|
|
|
initiatingDoc: document };
|
|
|
|
if (!this.valueIsTyped)
|
|
|
|
params.isUTF8 = true;
|
|
|
|
openUILinkIn(url, where, params);
|
|
|
|
}
|
2011-05-19 23:44:01 +00:00
|
|
|
} else {
|
2013-06-25 01:26:22 +00:00
|
|
|
if (matchLastLocationChange) {
|
|
|
|
loadCurrent();
|
|
|
|
}
|
2010-11-05 10:56:49 +00:00
|
|
|
}
|
2013-06-25 01:26:22 +00:00
|
|
|
}.bind(this));
|
2008-09-25 11:33:51 +00:00
|
|
|
]]></body>
|
|
|
|
</method>
|
|
|
|
|
|
|
|
<method name="_canonizeURL">
|
|
|
|
<parameter name="aTriggeringEvent"/>
|
|
|
|
<body><![CDATA[
|
2013-06-25 01:26:22 +00:00
|
|
|
return Task.spawn(function() {
|
|
|
|
var url = this.value;
|
|
|
|
if (!url)
|
|
|
|
throw new Task.Result(["", null, false]);
|
2008-09-25 11:33:51 +00:00
|
|
|
|
2013-06-25 01:26:22 +00:00
|
|
|
// Only add the suffix when the URL bar value isn't already "URL-like",
|
|
|
|
// and only if we get a keyboard event, to match user expectations.
|
|
|
|
if (/^\s*[^.:\/\s]+(?:\/.*|\s*)$/i.test(url) &&
|
|
|
|
(aTriggeringEvent instanceof KeyEvent)) {
|
2008-09-25 11:33:51 +00:00
|
|
|
#ifdef XP_MACOSX
|
2013-06-25 01:26:22 +00:00
|
|
|
let accel = aTriggeringEvent.metaKey;
|
2008-09-25 11:33:51 +00:00
|
|
|
#else
|
2013-06-25 01:26:22 +00:00
|
|
|
let accel = aTriggeringEvent.ctrlKey;
|
2008-09-25 11:33:51 +00:00
|
|
|
#endif
|
2013-06-25 01:26:22 +00:00
|
|
|
let shift = aTriggeringEvent.shiftKey;
|
|
|
|
|
|
|
|
let suffix = "";
|
|
|
|
|
|
|
|
switch (true) {
|
|
|
|
case (accel && shift):
|
|
|
|
suffix = ".org/";
|
|
|
|
break;
|
|
|
|
case (shift):
|
|
|
|
suffix = ".net/";
|
|
|
|
break;
|
|
|
|
case (accel):
|
|
|
|
try {
|
|
|
|
suffix = gPrefService.getCharPref("browser.fixup.alternate.suffix");
|
|
|
|
if (suffix.charAt(suffix.length - 1) != "/")
|
|
|
|
suffix += "/";
|
|
|
|
} catch(e) {
|
|
|
|
suffix = ".com/";
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2008-09-25 11:33:51 +00:00
|
|
|
|
2013-06-25 01:26:22 +00:00
|
|
|
if (suffix) {
|
|
|
|
// trim leading/trailing spaces (bug 233205)
|
|
|
|
url = url.trim();
|
2008-09-25 11:33:51 +00:00
|
|
|
|
2013-06-25 01:26:22 +00:00
|
|
|
// Tack www. and suffix on. If user has appended directories, insert
|
|
|
|
// suffix before them (bug 279035). Be careful not to get two slashes.
|
2010-09-16 07:51:24 +00:00
|
|
|
|
2013-06-25 01:26:22 +00:00
|
|
|
let firstSlash = url.indexOf("/");
|
2010-09-16 07:51:24 +00:00
|
|
|
|
2013-06-25 01:26:22 +00:00
|
|
|
if (firstSlash >= 0) {
|
|
|
|
url = url.substring(0, firstSlash) + suffix +
|
|
|
|
url.substring(firstSlash + 1);
|
|
|
|
} else {
|
|
|
|
url = url + suffix;
|
|
|
|
}
|
2008-09-25 11:33:51 +00:00
|
|
|
|
2013-06-25 01:26:22 +00:00
|
|
|
url = "http://www." + url;
|
|
|
|
}
|
2008-09-25 11:33:51 +00:00
|
|
|
}
|
|
|
|
|
2013-06-25 01:26:22 +00:00
|
|
|
let data = yield getShortcutOrURIAndPostData(url);
|
2008-09-25 11:33:51 +00:00
|
|
|
|
2013-06-25 01:26:22 +00:00
|
|
|
throw new Task.Result([data.url, data.postData, data.mayInheritPrincipal]);
|
|
|
|
}.bind(this));
|
2008-09-25 11:33:51 +00:00
|
|
|
]]></body>
|
|
|
|
</method>
|
2010-03-26 21:59:02 +00:00
|
|
|
|
|
|
|
<field name="_contentIsCropped">false</field>
|
2008-09-25 11:33:51 +00:00
|
|
|
|
2007-06-27 22:31:06 +00:00
|
|
|
<method name="_initURLTooltip">
|
|
|
|
<body><![CDATA[
|
2010-03-26 21:59:02 +00:00
|
|
|
if (this.focused || !this._contentIsCropped)
|
2007-10-26 02:53:01 +00:00
|
|
|
return;
|
2012-09-05 15:43:19 +00:00
|
|
|
this.inputField.setAttribute("tooltiptext", this.value);
|
2007-06-27 22:31:06 +00:00
|
|
|
]]></body>
|
|
|
|
</method>
|
|
|
|
|
|
|
|
<method name="_hideURLTooltip">
|
|
|
|
<body><![CDATA[
|
2012-09-05 15:43:19 +00:00
|
|
|
this.inputField.removeAttribute("tooltiptext");
|
2007-06-27 22:31:06 +00:00
|
|
|
]]></body>
|
|
|
|
</method>
|
|
|
|
|
2007-11-28 22:36:24 +00:00
|
|
|
<method name="onDragOver">
|
2009-06-21 00:04:07 +00:00
|
|
|
<parameter name="aEvent"/>
|
2007-11-28 22:36:24 +00:00
|
|
|
<body>
|
2009-06-21 00:04:07 +00:00
|
|
|
var types = aEvent.dataTransfer.types;
|
|
|
|
if (types.contains("application/x-moz-file") ||
|
|
|
|
types.contains("text/x-moz-url") ||
|
|
|
|
types.contains("text/uri-list") ||
|
|
|
|
types.contains("text/unicode"))
|
|
|
|
aEvent.preventDefault();
|
2007-11-28 22:36:24 +00:00
|
|
|
</body>
|
|
|
|
</method>
|
|
|
|
|
|
|
|
<method name="onDrop">
|
|
|
|
<parameter name="aEvent"/>
|
|
|
|
<body><![CDATA[
|
2010-04-18 18:27:18 +00:00
|
|
|
let url = browserDragAndDrop.drop(aEvent, { })
|
2007-11-28 22:36:24 +00:00
|
|
|
|
|
|
|
// The URL bar automatically handles inputs with newline characters,
|
2009-06-21 00:04:07 +00:00
|
|
|
// so we can get away with treating text/x-moz-url flavours as text/plain.
|
2007-11-28 22:36:24 +00:00
|
|
|
if (url) {
|
2010-04-18 18:27:18 +00:00
|
|
|
aEvent.preventDefault();
|
2007-12-29 03:17:07 +00:00
|
|
|
this.value = url;
|
2008-02-07 09:01:05 +00:00
|
|
|
SetPageProxyState("invalid");
|
2011-05-11 13:15:34 +00:00
|
|
|
this.focus();
|
2007-11-28 22:36:24 +00:00
|
|
|
try {
|
2011-06-23 08:13:41 +00:00
|
|
|
urlSecurityCheck(url,
|
2007-11-28 22:36:24 +00:00
|
|
|
gBrowser.contentPrincipal,
|
2007-12-29 03:17:07 +00:00
|
|
|
Ci.nsIScriptSecurityManager.DISALLOW_INHERIT_PRINCIPAL);
|
|
|
|
} catch (ex) {
|
|
|
|
return;
|
|
|
|
}
|
2008-09-25 11:33:51 +00:00
|
|
|
this.handleCommand();
|
2007-11-28 22:36:24 +00:00
|
|
|
}
|
|
|
|
]]></body>
|
|
|
|
</method>
|
|
|
|
|
2008-10-08 14:42:39 +00:00
|
|
|
<method name="_getSelectedValueForClipboard">
|
|
|
|
<body><![CDATA[
|
2010-05-14 18:14:43 +00:00
|
|
|
// Grab the actual input field's value, not our value, which could include moz-action:
|
|
|
|
var inputVal = this.inputField.value;
|
2011-06-26 01:08:31 +00:00
|
|
|
var selectedVal = inputVal.substring(this.selectionStart, this.selectionEnd);
|
2008-10-08 14:42:39 +00:00
|
|
|
|
2012-01-09 09:53:17 +00:00
|
|
|
// If the selection doesn't start at the beginning or doesn't span the full domain or
|
|
|
|
// the URL bar is modified, nothing else to do here.
|
2011-09-20 03:35:33 +00:00
|
|
|
if (this.selectionStart > 0 || this.valueIsTyped)
|
|
|
|
return selectedVal;
|
2012-01-09 09:53:17 +00:00
|
|
|
// The selection doesn't span the full domain if it doesn't contain a slash and is
|
|
|
|
// followed by some character other than a slash.
|
2012-09-08 20:58:23 +00:00
|
|
|
if (!selectedVal.contains("/")) {
|
2012-01-09 09:53:17 +00:00
|
|
|
let remainder = inputVal.replace(selectedVal, "");
|
|
|
|
if (remainder != "" && remainder[0] != "/")
|
|
|
|
return selectedVal;
|
|
|
|
}
|
2011-09-20 03:35:33 +00:00
|
|
|
|
|
|
|
let uriFixup = Cc["@mozilla.org/docshell/urifixup;1"].getService(Ci.nsIURIFixup);
|
|
|
|
|
|
|
|
let uri;
|
|
|
|
try {
|
2011-10-06 22:35:17 +00:00
|
|
|
uri = uriFixup.createFixupURI(inputVal, Ci.nsIURIFixup.FIXUP_FLAG_USE_UTF8);
|
2011-09-20 03:35:33 +00:00
|
|
|
} catch (e) {}
|
|
|
|
if (!uri)
|
2011-06-26 01:08:31 +00:00
|
|
|
return selectedVal;
|
2008-10-08 14:43:42 +00:00
|
|
|
|
2011-07-19 08:00:45 +00:00
|
|
|
// Only copy exposable URIs
|
|
|
|
try {
|
2011-09-20 03:35:33 +00:00
|
|
|
uri = uriFixup.createExposableURI(uri);
|
2011-07-19 08:00:45 +00:00
|
|
|
} catch (ex) {}
|
2008-10-08 14:43:42 +00:00
|
|
|
|
2011-06-26 01:08:31 +00:00
|
|
|
// If the entire URL is selected, just use the actual loaded URI.
|
|
|
|
if (inputVal == selectedVal) {
|
|
|
|
// ... but only if isn't a javascript: or data: URI, since those
|
|
|
|
// are hard to read when encoded
|
|
|
|
if (!uri.schemeIs("javascript") && !uri.schemeIs("data")) {
|
2008-10-08 14:43:42 +00:00
|
|
|
// Parentheses are known to confuse third-party applications (bug 458565).
|
2011-06-26 01:08:31 +00:00
|
|
|
selectedVal = uri.spec.replace(/[()]/g, function (c) escape(c));
|
2008-10-08 14:43:42 +00:00
|
|
|
}
|
2011-06-26 01:08:31 +00:00
|
|
|
|
|
|
|
return selectedVal;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Just the beginning of the URL is selected, check for a trimmed
|
|
|
|
// value
|
|
|
|
let spec = uri.spec;
|
|
|
|
let trimmedSpec = this.trimValue(spec);
|
|
|
|
if (spec != trimmedSpec) {
|
|
|
|
// Prepend the portion that trimValue removed from the beginning.
|
|
|
|
// This assumes trimValue will only truncate the URL at
|
|
|
|
// the beginning or end (or both).
|
|
|
|
let trimmedSegments = spec.split(trimmedSpec);
|
|
|
|
selectedVal = trimmedSegments[0] + selectedVal;
|
2008-10-08 14:42:39 +00:00
|
|
|
}
|
|
|
|
|
2011-06-26 01:08:31 +00:00
|
|
|
return selectedVal;
|
2008-10-08 14:42:39 +00:00
|
|
|
]]></body>
|
|
|
|
</method>
|
|
|
|
|
2007-06-27 22:31:06 +00:00
|
|
|
<field name="_copyCutController"><![CDATA[
|
|
|
|
({
|
|
|
|
urlbar: this,
|
|
|
|
doCommand: function(aCommand) {
|
2007-07-04 21:30:08 +00:00
|
|
|
var urlbar = this.urlbar;
|
2008-10-08 14:42:39 +00:00
|
|
|
var val = urlbar._getSelectedValueForClipboard();
|
|
|
|
if (!val)
|
2007-07-04 21:30:08 +00:00
|
|
|
return;
|
2008-01-29 07:50:13 +00:00
|
|
|
|
2008-10-08 14:42:39 +00:00
|
|
|
if (aCommand == "cmd_cut" && this.isCommandEnabled(aCommand)) {
|
|
|
|
let start = urlbar.selectionStart;
|
|
|
|
let end = urlbar.selectionEnd;
|
2012-08-21 07:56:59 +00:00
|
|
|
urlbar.inputField.value = urlbar.inputField.value.substring(0, start) +
|
|
|
|
urlbar.inputField.value.substring(end);
|
2008-10-08 14:42:39 +00:00
|
|
|
urlbar.selectionStart = urlbar.selectionEnd = start;
|
2012-08-21 07:56:59 +00:00
|
|
|
urlbar.removeAttribute("actiontype");
|
2008-10-08 14:42:39 +00:00
|
|
|
SetPageProxyState("invalid");
|
2007-07-04 21:30:08 +00:00
|
|
|
}
|
2008-10-08 14:42:39 +00:00
|
|
|
|
2008-01-12 10:19:31 +00:00
|
|
|
Cc["@mozilla.org/widget/clipboardhelper;1"]
|
|
|
|
.getService(Ci.nsIClipboardHelper)
|
2012-04-17 02:14:01 +00:00
|
|
|
.copyString(val, document);
|
2007-06-27 22:31:06 +00:00
|
|
|
},
|
|
|
|
supportsCommand: function(aCommand) {
|
|
|
|
switch (aCommand) {
|
|
|
|
case "cmd_copy":
|
|
|
|
case "cmd_cut":
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
},
|
|
|
|
isCommandEnabled: function(aCommand) {
|
2008-02-10 06:45:56 +00:00
|
|
|
return this.supportsCommand(aCommand) &&
|
|
|
|
(aCommand != "cmd_cut" || !this.urlbar.readOnly) &&
|
|
|
|
this.urlbar.selectionStart < this.urlbar.selectionEnd;
|
2007-06-27 22:31:06 +00:00
|
|
|
},
|
|
|
|
onEvent: function(aEventName) {}
|
|
|
|
})
|
|
|
|
]]></field>
|
|
|
|
|
|
|
|
<method name="observe">
|
|
|
|
<parameter name="aSubject"/>
|
|
|
|
<parameter name="aTopic"/>
|
|
|
|
<parameter name="aData"/>
|
|
|
|
<body><![CDATA[
|
|
|
|
if (aTopic == "nsPref:changed") {
|
2010-02-06 10:40:06 +00:00
|
|
|
switch (aData) {
|
2007-06-27 22:31:06 +00:00
|
|
|
case "clickSelectsAll":
|
2007-08-04 08:35:28 +00:00
|
|
|
case "doubleClickSelectsAll":
|
|
|
|
this[aData] = this._prefs.getBoolPref(aData);
|
2007-06-27 22:31:06 +00:00
|
|
|
break;
|
2007-07-03 17:40:40 +00:00
|
|
|
case "autoFill":
|
|
|
|
this.completeDefaultIndex = this._prefs.getBoolPref(aData);
|
|
|
|
break;
|
2009-06-17 15:27:04 +00:00
|
|
|
case "delay":
|
|
|
|
this.timeout = this._prefs.getIntPref(aData);
|
|
|
|
break;
|
2011-05-02 17:50:18 +00:00
|
|
|
case "formatting.enabled":
|
|
|
|
this._formattingEnabled = this._prefs.getBoolPref(aData);
|
|
|
|
break;
|
2011-06-23 08:13:41 +00:00
|
|
|
case "trimURLs":
|
|
|
|
this._mayTrimURLs = this._prefs.getBoolPref(aData);
|
|
|
|
break;
|
2007-06-27 22:31:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
]]></body>
|
|
|
|
</method>
|
2007-08-04 08:35:28 +00:00
|
|
|
|
|
|
|
<method name="handleEvent">
|
|
|
|
<parameter name="aEvent"/>
|
|
|
|
<body><![CDATA[
|
2007-10-26 02:53:01 +00:00
|
|
|
switch (aEvent.type) {
|
|
|
|
case "mousedown":
|
|
|
|
if (this.doubleClickSelectsAll &&
|
|
|
|
aEvent.button == 0 && aEvent.detail == 2) {
|
|
|
|
this.editor.selectAll();
|
|
|
|
aEvent.preventDefault();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case "mousemove":
|
|
|
|
this._initURLTooltip();
|
|
|
|
break;
|
|
|
|
case "mouseout":
|
|
|
|
this._hideURLTooltip();
|
|
|
|
break;
|
2010-03-26 21:59:02 +00:00
|
|
|
case "overflow":
|
|
|
|
this._contentIsCropped = true;
|
|
|
|
break;
|
|
|
|
case "underflow":
|
|
|
|
this._contentIsCropped = false;
|
|
|
|
this._hideURLTooltip();
|
|
|
|
break;
|
2007-08-04 08:35:28 +00:00
|
|
|
}
|
|
|
|
]]></body>
|
|
|
|
</method>
|
2008-03-12 23:39:40 +00:00
|
|
|
|
|
|
|
<property name="textValue"
|
|
|
|
onget="return this.value;">
|
|
|
|
<setter>
|
|
|
|
<![CDATA[
|
|
|
|
try {
|
2009-07-29 05:55:18 +00:00
|
|
|
val = losslessDecodeURI(makeURI(val));
|
2008-03-28 08:45:18 +00:00
|
|
|
} catch (ex) { }
|
2012-01-19 11:31:27 +00:00
|
|
|
|
|
|
|
// Trim popup selected values, but never trim results coming from
|
|
|
|
// autofill.
|
|
|
|
if (this.popup.selectedIndex == -1)
|
|
|
|
this._disableTrim = true;
|
2008-03-28 08:45:18 +00:00
|
|
|
this.value = val;
|
2012-01-19 11:31:27 +00:00
|
|
|
this._disableTrim = false;
|
2008-03-12 23:39:40 +00:00
|
|
|
|
|
|
|
// Completing a result should simulate the user typing the result, so
|
|
|
|
// fire an input event.
|
|
|
|
let evt = document.createEvent("UIEvents");
|
|
|
|
evt.initUIEvent("input", true, false, window, 0);
|
|
|
|
this.mIgnoreInput = true;
|
|
|
|
this.dispatchEvent(evt);
|
|
|
|
this.mIgnoreInput = false;
|
|
|
|
|
|
|
|
return this.value;
|
|
|
|
]]>
|
|
|
|
</setter>
|
|
|
|
</property>
|
2010-02-11 08:32:25 +00:00
|
|
|
|
2010-03-26 21:59:02 +00:00
|
|
|
<method name="_parseActionUrl">
|
|
|
|
<parameter name="aUrl"/>
|
|
|
|
<body><![CDATA[
|
2012-09-23 19:09:29 +00:00
|
|
|
if (!aUrl.startsWith("moz-action:"))
|
2010-03-26 21:59:02 +00:00
|
|
|
return null;
|
|
|
|
|
|
|
|
// url is in the format moz-action:ACTION,PARAM
|
|
|
|
let [, action, param] = aUrl.match(/^moz-action:([^,]+),(.*)$/);
|
|
|
|
return {type: action, param: param};
|
|
|
|
]]></body>
|
|
|
|
</method>
|
2010-09-15 05:41:16 +00:00
|
|
|
|
2010-12-11 02:32:14 +00:00
|
|
|
<field name="_numNoActionsKeys"><![CDATA[
|
|
|
|
0
|
|
|
|
]]></field>
|
|
|
|
|
|
|
|
<method name="_clearNoActions">
|
|
|
|
<parameter name="aURL"/>
|
|
|
|
<body><![CDATA[
|
|
|
|
this._numNoActionsKeys = 0;
|
|
|
|
this.popup.removeAttribute("noactions");
|
|
|
|
let action = this._parseActionUrl(this._value);
|
|
|
|
if (action)
|
|
|
|
this.setAttribute("actiontype", action.type);
|
|
|
|
]]></body>
|
|
|
|
</method>
|
2007-06-27 22:31:06 +00:00
|
|
|
</implementation>
|
|
|
|
|
|
|
|
<handlers>
|
2010-12-11 02:32:14 +00:00
|
|
|
<handler event="keydown"><![CDATA[
|
|
|
|
if ((event.keyCode === KeyEvent.DOM_VK_ALT ||
|
|
|
|
event.keyCode === KeyEvent.DOM_VK_SHIFT) &&
|
|
|
|
this.popup.selectedIndex >= 0) {
|
|
|
|
this._numNoActionsKeys++;
|
|
|
|
this.popup.setAttribute("noactions", "true");
|
|
|
|
this.removeAttribute("actiontype");
|
|
|
|
}
|
|
|
|
]]></handler>
|
|
|
|
|
|
|
|
<handler event="keyup"><![CDATA[
|
|
|
|
if ((event.keyCode === KeyEvent.DOM_VK_ALT ||
|
|
|
|
event.keyCode === KeyEvent.DOM_VK_SHIFT) &&
|
|
|
|
this._numNoActionsKeys > 0) {
|
|
|
|
this._numNoActionsKeys--;
|
|
|
|
if (this._numNoActionsKeys == 0)
|
|
|
|
this._clearNoActions();
|
|
|
|
}
|
|
|
|
]]></handler>
|
|
|
|
|
|
|
|
<handler event="blur"><![CDATA[
|
|
|
|
this._clearNoActions();
|
2011-05-12 21:38:40 +00:00
|
|
|
this.formatValue();
|
2010-12-11 02:32:14 +00:00
|
|
|
]]></handler>
|
|
|
|
|
2012-05-29 19:27:06 +00:00
|
|
|
<handler event="dragstart" phase="capturing"><![CDATA[
|
2009-06-18 08:57:14 +00:00
|
|
|
// Drag only if the gesture starts from the input field.
|
|
|
|
if (event.originalTarget != this.inputField)
|
|
|
|
return;
|
|
|
|
|
|
|
|
// Drag only if the entire value is selected and it's a valid URI.
|
|
|
|
var isFullSelection = this.selectionStart == 0 &&
|
|
|
|
this.selectionEnd == this.textLength;
|
|
|
|
if (!isFullSelection ||
|
|
|
|
this.getAttribute("pageproxystate") != "valid")
|
|
|
|
return;
|
|
|
|
|
|
|
|
var urlString = content.location.href;
|
|
|
|
var title = content.document.title || urlString;
|
|
|
|
var htmlString = "<a href=\"" + urlString + "\">" + urlString + "</a>";
|
|
|
|
|
|
|
|
var dt = event.dataTransfer;
|
|
|
|
dt.setData("text/x-moz-url", urlString + "\n" + title);
|
|
|
|
dt.setData("text/unicode", urlString);
|
|
|
|
dt.setData("text/html", htmlString);
|
|
|
|
|
|
|
|
dt.effectAllowed = "copyLink";
|
|
|
|
event.stopPropagation();
|
|
|
|
]]></handler>
|
2010-09-15 05:41:16 +00:00
|
|
|
|
|
|
|
<handler event="focus" phase="capturing"><![CDATA[
|
|
|
|
this._hideURLTooltip();
|
2011-05-12 21:38:40 +00:00
|
|
|
this._clearFormatting();
|
2010-09-15 05:41:16 +00:00
|
|
|
]]></handler>
|
|
|
|
|
2009-06-21 00:04:07 +00:00
|
|
|
<handler event="dragover" phase="capturing" action="this.onDragOver(event, this);"/>
|
|
|
|
<handler event="drop" phase="capturing" action="this.onDrop(event, this);"/>
|
2008-10-08 14:42:39 +00:00
|
|
|
<handler event="select"><![CDATA[
|
|
|
|
if (!Cc["@mozilla.org/widget/clipboard;1"]
|
|
|
|
.getService(Ci.nsIClipboard)
|
|
|
|
.supportsSelectionClipboard())
|
|
|
|
return;
|
|
|
|
|
|
|
|
var val = this._getSelectedValueForClipboard();
|
|
|
|
if (!val)
|
|
|
|
return;
|
|
|
|
|
|
|
|
Cc["@mozilla.org/widget/clipboardhelper;1"]
|
|
|
|
.getService(Ci.nsIClipboardHelper)
|
2012-07-01 18:18:23 +00:00
|
|
|
.copyStringToClipboard(val, Ci.nsIClipboard.kSelectionClipboard, document);
|
2008-10-08 14:42:39 +00:00
|
|
|
]]></handler>
|
2007-06-27 22:31:06 +00:00
|
|
|
</handlers>
|
|
|
|
|
|
|
|
</binding>
|
|
|
|
|
2007-12-13 21:21:16 +00:00
|
|
|
<!-- Note: this binding is applied to the autocomplete popup used in the Search bar and in web page content -->
|
|
|
|
<binding id="browser-autocomplete-result-popup" extends="chrome://global/content/bindings/autocomplete.xml#autocomplete-result-popup">
|
2007-06-05 04:51:15 +00:00
|
|
|
<implementation>
|
2007-12-04 21:00:12 +00:00
|
|
|
<method name="openAutocompletePopup">
|
|
|
|
<parameter name="aInput"/>
|
|
|
|
<parameter name="aElement"/>
|
|
|
|
<body>
|
|
|
|
<![CDATA[
|
|
|
|
// initially the panel is hidden
|
|
|
|
// to avoid impacting startup / new window performance
|
|
|
|
aInput.popup.hidden = false;
|
|
|
|
|
|
|
|
// this method is defined on the base binding
|
|
|
|
this._openAutocompletePopup(aInput, aElement);
|
|
|
|
]]></body>
|
|
|
|
</method>
|
2007-11-11 18:36:52 +00:00
|
|
|
|
2007-06-05 04:51:15 +00:00
|
|
|
<method name="onPopupClick">
|
|
|
|
<parameter name="aEvent"/>
|
|
|
|
<body><![CDATA[
|
2007-12-13 21:21:16 +00:00
|
|
|
// Ignore all right-clicks
|
|
|
|
if (aEvent.button == 2)
|
|
|
|
return;
|
|
|
|
|
2007-06-05 04:51:15 +00:00
|
|
|
var controller = this.view.QueryInterface(Components.interfaces.nsIAutoCompleteController);
|
|
|
|
|
2007-12-13 21:21:16 +00:00
|
|
|
// Check for unmodified left-click, and use default behavior
|
2007-06-05 04:51:15 +00:00
|
|
|
if (aEvent.button == 0 && !aEvent.shiftKey && !aEvent.ctrlKey &&
|
|
|
|
!aEvent.altKey && !aEvent.metaKey) {
|
2008-02-29 13:07:02 +00:00
|
|
|
controller.handleEnter(true);
|
2007-12-13 21:21:16 +00:00
|
|
|
return;
|
2007-06-05 04:51:15 +00:00
|
|
|
}
|
2007-12-13 21:21:16 +00:00
|
|
|
|
|
|
|
// Check for middle-click or modified clicks on the search bar
|
|
|
|
var searchBar = BrowserSearch.searchBar;
|
|
|
|
if (searchBar && searchBar.textbox == this.mInput) {
|
|
|
|
// Handle search bar popup clicks
|
|
|
|
var search = controller.getValueAt(this.selectedIndex);
|
2010-09-16 07:51:24 +00:00
|
|
|
|
2007-12-13 21:21:16 +00:00
|
|
|
// close the autocomplete popup and revert the entered search term
|
|
|
|
this.closePopup();
|
|
|
|
controller.handleEscape();
|
|
|
|
|
|
|
|
// Fill in the search bar's value
|
|
|
|
searchBar.value = search;
|
|
|
|
|
|
|
|
// open the search results according to the clicking subtlety
|
|
|
|
var where = whereToOpenLink(aEvent, false, true);
|
|
|
|
searchBar.doSearch(search, where);
|
2007-06-05 04:51:15 +00:00
|
|
|
}
|
2007-12-04 21:00:12 +00:00
|
|
|
]]></body>
|
|
|
|
</method>
|
|
|
|
</implementation>
|
|
|
|
</binding>
|
2007-11-30 04:57:57 +00:00
|
|
|
|
2007-12-04 21:00:12 +00:00
|
|
|
<binding id="urlbar-rich-result-popup" extends="chrome://global/content/bindings/autocomplete.xml#autocomplete-rich-result-popup">
|
|
|
|
<implementation>
|
2007-11-30 04:57:57 +00:00
|
|
|
<field name="_maxResults">0</field>
|
|
|
|
|
2007-12-05 06:19:38 +00:00
|
|
|
<field name="_bundle" readonly="true">
|
|
|
|
Cc["@mozilla.org/intl/stringbundle;1"].
|
|
|
|
getService(Ci.nsIStringBundleService).
|
|
|
|
createBundle("chrome://browser/locale/places/places.properties");
|
|
|
|
</field>
|
|
|
|
|
2007-11-30 04:57:57 +00:00
|
|
|
<property name="maxResults" readonly="true">
|
|
|
|
<getter>
|
|
|
|
<![CDATA[
|
|
|
|
if (!this._maxResults) {
|
|
|
|
var prefService =
|
|
|
|
Components.classes["@mozilla.org/preferences-service;1"]
|
|
|
|
.getService(Components.interfaces.nsIPrefBranch);
|
|
|
|
this._maxResults = prefService.getIntPref("browser.urlbar.maxRichResults");
|
|
|
|
}
|
|
|
|
return this._maxResults;
|
|
|
|
]]>
|
|
|
|
</getter>
|
|
|
|
</property>
|
|
|
|
|
2007-12-04 21:00:12 +00:00
|
|
|
<method name="openAutocompletePopup">
|
|
|
|
<parameter name="aInput"/>
|
|
|
|
<parameter name="aElement"/>
|
|
|
|
<body>
|
|
|
|
<![CDATA[
|
|
|
|
// initially the panel is hidden
|
|
|
|
// to avoid impacting startup / new window performance
|
|
|
|
aInput.popup.hidden = false;
|
|
|
|
|
|
|
|
// this method is defined on the base binding
|
|
|
|
this._openAutocompletePopup(aInput, aElement);
|
|
|
|
]]></body>
|
|
|
|
</method>
|
|
|
|
|
2007-11-30 04:57:57 +00:00
|
|
|
<method name="onPopupClick">
|
|
|
|
<parameter name="aEvent"/>
|
|
|
|
<body>
|
|
|
|
<![CDATA[
|
2007-12-13 21:21:16 +00:00
|
|
|
// Ignore right-clicks
|
|
|
|
if (aEvent.button == 2)
|
|
|
|
return;
|
|
|
|
|
2007-11-30 04:57:57 +00:00
|
|
|
var controller = this.view.QueryInterface(Components.interfaces.nsIAutoCompleteController);
|
|
|
|
|
2007-12-13 21:21:16 +00:00
|
|
|
// Check for unmodified left-click, and use default behavior
|
2007-11-30 04:57:57 +00:00
|
|
|
if (aEvent.button == 0 && !aEvent.shiftKey && !aEvent.ctrlKey &&
|
|
|
|
!aEvent.altKey && !aEvent.metaKey) {
|
2008-02-29 13:07:02 +00:00
|
|
|
controller.handleEnter(true);
|
2007-12-13 21:21:16 +00:00
|
|
|
return;
|
2007-11-30 04:57:57 +00:00
|
|
|
}
|
2007-12-13 21:21:16 +00:00
|
|
|
|
|
|
|
// Check for middle-click or modified clicks on the URL bar
|
|
|
|
if (gURLBar && this.mInput == gURLBar) {
|
|
|
|
var url = controller.getValueAt(this.selectedIndex);
|
|
|
|
|
|
|
|
// close the autocomplete popup and revert the entered address
|
|
|
|
this.closePopup();
|
|
|
|
controller.handleEscape();
|
|
|
|
|
2010-03-26 21:59:02 +00:00
|
|
|
// Check if this is meant to be an action
|
|
|
|
let action = this.mInput._parseActionUrl(url);
|
|
|
|
if (action) {
|
|
|
|
if (action.type == "switchtab")
|
|
|
|
url = action.param;
|
|
|
|
else
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-12-13 21:21:16 +00:00
|
|
|
// respect the usual clicking subtleties
|
|
|
|
openUILink(url, aEvent);
|
2007-11-30 04:57:57 +00:00
|
|
|
}
|
|
|
|
]]>
|
|
|
|
</body>
|
|
|
|
</method>
|
2007-12-05 06:19:38 +00:00
|
|
|
|
|
|
|
<method name="createResultLabel">
|
|
|
|
<parameter name="aTitle"/>
|
|
|
|
<parameter name="aUrl"/>
|
|
|
|
<parameter name="aType"/>
|
|
|
|
<body>
|
|
|
|
<![CDATA[
|
|
|
|
var label = aTitle + " " + aUrl;
|
|
|
|
// convert aType (ex: "ac-result-type-<aType>") to text to be spoke aloud
|
|
|
|
// by screen readers. convert "tag" and "bookmark" to the localized versions,
|
|
|
|
// but don't do anything for "favicon" (the default)
|
|
|
|
if (aType != "favicon") {
|
|
|
|
label += " " + this._bundle.GetStringFromName(aType + "ResultLabel");
|
|
|
|
}
|
|
|
|
return label;
|
|
|
|
]]>
|
|
|
|
</body>
|
|
|
|
</method>
|
|
|
|
|
2007-06-05 04:51:15 +00:00
|
|
|
</implementation>
|
|
|
|
</binding>
|
2010-08-30 16:55:17 +00:00
|
|
|
|
2011-01-03 19:40:47 +00:00
|
|
|
<binding id="addon-progress-notification" extends="chrome://global/content/bindings/notification.xml#popup-notification">
|
|
|
|
<content align="start">
|
|
|
|
<xul:image class="popup-notification-icon"
|
2011-12-18 03:01:59 +00:00
|
|
|
xbl:inherits="popupid,src=icon"/>
|
2011-01-03 19:40:47 +00:00
|
|
|
<xul:vbox flex="1">
|
|
|
|
<xul:description class="popup-notification-description addon-progress-description"
|
|
|
|
xbl:inherits="xbl:text=label"/>
|
|
|
|
<xul:spacer flex="1"/>
|
|
|
|
<xul:hbox align="center">
|
|
|
|
<xul:progressmeter anonid="progressmeter" flex="1" mode="undetermined" class="popup-progress-meter"/>
|
|
|
|
<xul:button anonid="cancel" class="popup-progress-cancel" oncommand="document.getBindingParent(this).cancel()"/>
|
|
|
|
</xul:hbox>
|
|
|
|
<xul:label anonid="progresstext" class="popup-progress-label"/>
|
2011-02-12 08:32:07 +00:00
|
|
|
<xul:hbox class="popup-notification-button-container"
|
|
|
|
pack="end" align="center">
|
2011-01-03 19:40:47 +00:00
|
|
|
<xul:button anonid="button"
|
|
|
|
class="popup-notification-menubutton"
|
|
|
|
type="menu-button"
|
|
|
|
xbl:inherits="oncommand=buttoncommand,label=buttonlabel,accesskey=buttonaccesskey">
|
|
|
|
<xul:menupopup anonid="menupopup"
|
|
|
|
xbl:inherits="oncommand=menucommand">
|
|
|
|
<children/>
|
|
|
|
<xul:menuitem class="menuitem-iconic popup-notification-closeitem"
|
|
|
|
label="&closeNotificationItem.label;"
|
|
|
|
xbl:inherits="oncommand=closeitemcommand"/>
|
|
|
|
</xul:menupopup>
|
|
|
|
</xul:button>
|
|
|
|
</xul:hbox>
|
|
|
|
</xul:vbox>
|
2011-01-14 00:07:44 +00:00
|
|
|
<xul:vbox pack="start">
|
|
|
|
<xul:toolbarbutton anonid="closebutton"
|
2011-05-24 15:43:05 +00:00
|
|
|
class="messageCloseButton popup-notification-closebutton tabbable"
|
2011-01-14 00:07:44 +00:00
|
|
|
xbl:inherits="oncommand=closebuttoncommand"
|
|
|
|
tooltiptext="&closeNotification.tooltip;"/>
|
|
|
|
</xul:vbox>
|
2011-01-03 19:40:47 +00:00
|
|
|
</content>
|
|
|
|
<implementation>
|
|
|
|
<constructor><![CDATA[
|
|
|
|
this.cancelbtn.setAttribute("tooltiptext", gNavigatorBundle.getString("addonDownloadCancelTooltip"));
|
|
|
|
|
|
|
|
this.notification.options.installs.forEach(function(aInstall) {
|
|
|
|
aInstall.addListener(this);
|
|
|
|
}, this);
|
|
|
|
|
|
|
|
// Calling updateProgress can sometimes cause this notification to be
|
|
|
|
// removed in the middle of refreshing the notification panel which
|
|
|
|
// makes the panel get refreshed again. Just initialise to the
|
2011-02-15 23:10:17 +00:00
|
|
|
// undetermined state and then schedule a proper check at the next
|
|
|
|
// opportunity
|
2011-01-03 19:40:47 +00:00
|
|
|
this.setProgress(0, -1);
|
2011-06-28 18:03:00 +00:00
|
|
|
this._updateProgressTimeout = setTimeout(this.updateProgress.bind(this), 0);
|
2011-01-03 19:40:47 +00:00
|
|
|
]]></constructor>
|
|
|
|
|
|
|
|
<destructor><![CDATA[
|
|
|
|
this.destroy();
|
|
|
|
]]></destructor>
|
|
|
|
|
|
|
|
<field name="progressmeter" readonly="true">
|
|
|
|
document.getAnonymousElementByAttribute(this, "anonid", "progressmeter");
|
|
|
|
</field>
|
|
|
|
<field name="progresstext" readonly="true">
|
|
|
|
document.getAnonymousElementByAttribute(this, "anonid", "progresstext");
|
|
|
|
</field>
|
|
|
|
<field name="cancelbtn" readonly="true">
|
|
|
|
document.getAnonymousElementByAttribute(this, "anonid", "cancel");
|
|
|
|
</field>
|
|
|
|
<field name="DownloadUtils" readonly="true">
|
|
|
|
let utils = {};
|
|
|
|
Components.utils.import("resource://gre/modules/DownloadUtils.jsm", utils);
|
|
|
|
utils.DownloadUtils;
|
|
|
|
</field>
|
|
|
|
|
|
|
|
<method name="destroy">
|
|
|
|
<body><![CDATA[
|
|
|
|
this.notification.options.installs.forEach(function(aInstall) {
|
|
|
|
aInstall.removeListener(this);
|
|
|
|
}, this);
|
2011-06-28 18:03:00 +00:00
|
|
|
clearTimeout(this._updateProgressTimeout);
|
2011-01-03 19:40:47 +00:00
|
|
|
]]></body>
|
|
|
|
</method>
|
|
|
|
|
|
|
|
<method name="setProgress">
|
|
|
|
<parameter name="aProgress"/>
|
|
|
|
<parameter name="aMaxProgress"/>
|
|
|
|
<body><![CDATA[
|
|
|
|
if (aMaxProgress == -1) {
|
|
|
|
this.progressmeter.mode = "undetermined";
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
this.progressmeter.mode = "determined";
|
|
|
|
this.progressmeter.value = (aProgress * 100) / aMaxProgress;
|
|
|
|
}
|
|
|
|
|
|
|
|
let now = Date.now();
|
|
|
|
|
|
|
|
if (!this.notification.lastUpdate) {
|
|
|
|
this.notification.lastUpdate = now;
|
|
|
|
this.notification.lastProgress = aProgress;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
let delta = now - this.notification.lastUpdate;
|
|
|
|
if ((delta < 400) && (aProgress < aMaxProgress))
|
|
|
|
return;
|
|
|
|
|
|
|
|
delta /= 1000;
|
|
|
|
|
|
|
|
// This code is taken from nsDownloadManager.cpp
|
|
|
|
let speed = (aProgress - this.notification.lastProgress) / delta;
|
|
|
|
if (this.notification.speed)
|
|
|
|
speed = speed * 0.9 + this.notification.speed * 0.1;
|
|
|
|
|
|
|
|
this.notification.lastUpdate = now;
|
|
|
|
this.notification.lastProgress = aProgress;
|
|
|
|
this.notification.speed = speed;
|
|
|
|
|
|
|
|
let status = null;
|
|
|
|
[status, this.notification.last] = this.DownloadUtils.getDownloadStatus(aProgress, aMaxProgress, speed, this.notification.last);
|
|
|
|
this.progresstext.value = status;
|
|
|
|
]]></body>
|
|
|
|
</method>
|
|
|
|
|
|
|
|
<method name="cancel">
|
|
|
|
<body><![CDATA[
|
|
|
|
// Cache these as cancelling the installs will remove this
|
2011-01-07 17:16:35 +00:00
|
|
|
// notification which will drop these references
|
2011-01-03 19:40:47 +00:00
|
|
|
let browser = this.notification.browser;
|
|
|
|
let contentWindow = this.notification.options.contentWindow;
|
|
|
|
let sourceURI = this.notification.options.sourceURI;
|
|
|
|
|
|
|
|
let installs = this.notification.options.installs;
|
|
|
|
installs.forEach(function(aInstall) {
|
|
|
|
try {
|
|
|
|
aInstall.cancel();
|
|
|
|
}
|
|
|
|
catch (e) {
|
|
|
|
// Cancel will throw if the download has already failed
|
|
|
|
}
|
|
|
|
}, this);
|
|
|
|
|
|
|
|
let anchorID = "addons-notification-icon";
|
|
|
|
let notificationID = "addon-install-cancelled";
|
|
|
|
let messageString = gNavigatorBundle.getString("addonDownloadCancelled");
|
|
|
|
messageString = PluralForm.get(installs.length, messageString);
|
|
|
|
let buttonText = gNavigatorBundle.getString("addonDownloadRestart");
|
|
|
|
buttonText = PluralForm.get(installs.length, buttonText);
|
|
|
|
|
|
|
|
let action = {
|
|
|
|
label: buttonText,
|
|
|
|
accessKey: gNavigatorBundle.getString("addonDownloadRestart.accessKey"),
|
|
|
|
callback: function() {
|
|
|
|
let weblistener = Cc["@mozilla.org/addons/web-install-listener;1"].
|
|
|
|
getService(Ci.amIWebInstallListener);
|
|
|
|
if (weblistener.onWebInstallRequested(contentWindow, sourceURI,
|
|
|
|
installs, installs.length)) {
|
|
|
|
installs.forEach(function(aInstall) {
|
|
|
|
aInstall.install();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
PopupNotifications.show(browser, notificationID, messageString,
|
|
|
|
anchorID, action);
|
|
|
|
]]></body>
|
|
|
|
</method>
|
|
|
|
|
|
|
|
<method name="updateProgress">
|
|
|
|
<body><![CDATA[
|
|
|
|
let downloadingCount = 0;
|
|
|
|
let progress = 0;
|
|
|
|
let maxProgress = 0;
|
|
|
|
|
|
|
|
this.notification.options.installs.forEach(function(aInstall) {
|
|
|
|
if (aInstall.maxProgress == -1)
|
|
|
|
maxProgress = -1;
|
|
|
|
progress += aInstall.progress;
|
|
|
|
if (maxProgress >= 0)
|
|
|
|
maxProgress += aInstall.maxProgress;
|
|
|
|
if (aInstall.state < AddonManager.STATE_DOWNLOADED)
|
|
|
|
downloadingCount++;
|
|
|
|
});
|
|
|
|
|
|
|
|
if (downloadingCount == 0) {
|
|
|
|
this.destroy();
|
|
|
|
PopupNotifications.remove(this.notification);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
this.setProgress(progress, maxProgress);
|
|
|
|
}
|
|
|
|
]]></body>
|
|
|
|
</method>
|
|
|
|
|
|
|
|
<method name="onDownloadProgress">
|
|
|
|
<body><![CDATA[
|
|
|
|
this.updateProgress();
|
|
|
|
]]></body>
|
|
|
|
</method>
|
|
|
|
|
|
|
|
<method name="onDownloadFailed">
|
|
|
|
<body><![CDATA[
|
|
|
|
this.updateProgress();
|
|
|
|
]]></body>
|
|
|
|
</method>
|
|
|
|
|
|
|
|
<method name="onDownloadCancelled">
|
|
|
|
<body><![CDATA[
|
|
|
|
this.updateProgress();
|
|
|
|
]]></body>
|
|
|
|
</method>
|
|
|
|
|
|
|
|
<method name="onDownloadEnded">
|
|
|
|
<body><![CDATA[
|
|
|
|
this.updateProgress();
|
|
|
|
]]></body>
|
|
|
|
</method>
|
|
|
|
</implementation>
|
|
|
|
</binding>
|
2011-01-11 10:59:42 +00:00
|
|
|
|
2013-03-27 17:01:46 +00:00
|
|
|
<binding id="identity-request-notification" extends="chrome://global/content/bindings/notification.xml#popup-notification">
|
|
|
|
<content align="start">
|
2012-06-13 01:16:00 +00:00
|
|
|
|
2013-03-27 17:01:46 +00:00
|
|
|
<xul:image class="popup-notification-icon"
|
|
|
|
xbl:inherits="popupid,src=icon"/>
|
2012-06-13 01:16:00 +00:00
|
|
|
|
2013-03-27 17:01:46 +00:00
|
|
|
<xul:vbox flex="1">
|
|
|
|
<xul:vbox anonid="identity-deck">
|
|
|
|
<xul:vbox flex="1" pack="center"> <!-- 1: add an email -->
|
|
|
|
<html:input type="email" anonid="email" required="required" size="30"/>
|
|
|
|
<xul:description anonid="newidentitydesc"/>
|
|
|
|
<xul:spacer flex="1"/>
|
|
|
|
<xul:label class="text-link custom-link small-margin" anonid="chooseemail" hidden="true"/>
|
|
|
|
</xul:vbox>
|
|
|
|
<xul:vbox flex="1" hidden="true"> <!-- 2: choose an email -->
|
|
|
|
<xul:description anonid="chooseidentitydesc"/>
|
|
|
|
<xul:radiogroup anonid="identities">
|
|
|
|
</xul:radiogroup>
|
|
|
|
<xul:label class="text-link custom-link" anonid="newemail"/>
|
|
|
|
</xul:vbox>
|
|
|
|
</xul:vbox>
|
|
|
|
<xul:hbox class="popup-notification-button-container"
|
|
|
|
pack="end" align="center">
|
|
|
|
<xul:label anonid="tos" class="text-link" hidden="true"/>
|
|
|
|
<xul:label anonid="privacypolicy" class="text-link" hidden="true"/>
|
|
|
|
<xul:spacer flex="1"/>
|
|
|
|
<xul:image anonid="throbber" src="chrome://browser/skin/tabbrowser/loading.png"
|
|
|
|
style="visibility:hidden" width="16" height="16"/>
|
|
|
|
<xul:button anonid="button"
|
|
|
|
type="menu-button"
|
|
|
|
class="popup-notification-menubutton"
|
|
|
|
xbl:inherits="oncommand=buttoncommand,label=buttonlabel,accesskey=buttonaccesskey">
|
|
|
|
<xul:menupopup anonid="menupopup"
|
|
|
|
xbl:inherits="oncommand=menucommand">
|
|
|
|
<children/>
|
|
|
|
<xul:menuitem class="menuitem-iconic popup-notification-closeitem"
|
|
|
|
label="&closeNotificationItem.label;"
|
|
|
|
xbl:inherits="oncommand=closeitemcommand"/>
|
|
|
|
</xul:menupopup>
|
|
|
|
</xul:button>
|
|
|
|
</xul:hbox>
|
|
|
|
</xul:vbox>
|
|
|
|
<xul:vbox pack="start">
|
|
|
|
<xul:toolbarbutton anonid="closebutton"
|
|
|
|
class="messageCloseButton popup-notification-closebutton tabbable"
|
|
|
|
xbl:inherits="oncommand=closebuttoncommand"
|
|
|
|
tooltiptext="&closeNotification.tooltip;"/>
|
|
|
|
</xul:vbox>
|
|
|
|
</content>
|
|
|
|
<implementation>
|
2013-03-27 15:19:09 +00:00
|
|
|
<constructor><![CDATA[
|
2013-03-27 17:01:46 +00:00
|
|
|
// this.notification.options.identity is used to pass identity-specific info to the binding
|
|
|
|
let origin = this.identity.origin
|
|
|
|
|
|
|
|
// Populate text
|
|
|
|
this.emailField.placeholder = gNavigatorBundle.
|
|
|
|
getString("identity.newIdentity.email.placeholder");
|
|
|
|
this.newIdentityDesc.textContent = gNavigatorBundle.getFormattedString(
|
|
|
|
"identity.newIdentity.description", [origin]);
|
|
|
|
this.chooseIdentityDesc.textContent = gNavigatorBundle.getFormattedString(
|
|
|
|
"identity.chooseIdentity.description", [origin]);
|
|
|
|
|
|
|
|
// Show optional terms of service and privacy policy links
|
|
|
|
this._populateLink(this.identity.termsOfService, "tos", "identity.termsOfService");
|
|
|
|
this._populateLink(this.identity.privacyPolicy, "privacypolicy", "identity.privacyPolicy");
|
|
|
|
|
|
|
|
// Populate the list of identities to choose from. The origin is used to provide
|
|
|
|
// better suggestions.
|
|
|
|
let identities = this.SignInToWebsiteUX.getIdentitiesForSite(origin);
|
|
|
|
|
|
|
|
this._populateIdentityList(identities);
|
|
|
|
|
|
|
|
if (typeof this.step == "undefined") {
|
|
|
|
// First opening of this notification
|
|
|
|
// Show the add email pane (0) if there are no existing identities otherwise show the list
|
|
|
|
this.step = "result" in identities && identities.result.length ? 1 : 0;
|
|
|
|
} else {
|
|
|
|
// Already opened so restore previous state
|
|
|
|
if (this.identity.typedEmail) {
|
|
|
|
this.emailField.value = this.identity.typedEmail;
|
|
|
|
}
|
|
|
|
if (this.identity.selected) {
|
|
|
|
// If the user already chose an identity then update the UI to reflect that
|
|
|
|
this.onIdentitySelected();
|
|
|
|
}
|
|
|
|
// Update the view for the step
|
|
|
|
this.step = this.step;
|
|
|
|
}
|
2012-06-13 01:16:00 +00:00
|
|
|
|
2013-03-27 17:01:46 +00:00
|
|
|
// Fire notification with the chosen identity when main button is clicked
|
|
|
|
this.button.addEventListener("command", this._onButtonCommand.bind(this), true);
|
2012-06-13 01:16:00 +00:00
|
|
|
|
2013-03-27 17:01:46 +00:00
|
|
|
// Do the same if enter is pressed in the email field
|
|
|
|
this.emailField.addEventListener("keypress", function emailFieldKeypress(aEvent) {
|
|
|
|
if (aEvent.keyCode != aEvent.DOM_VK_RETURN)
|
|
|
|
return;
|
|
|
|
this._onButtonCommand(aEvent);
|
|
|
|
}.bind(this));
|
|
|
|
|
|
|
|
this.addEmailLink.value = gNavigatorBundle.getString("identity.newIdentity.label");
|
|
|
|
this.addEmailLink.accessKey = gNavigatorBundle.getString("identity.newIdentity.accessKey");
|
|
|
|
this.addEmailLink.addEventListener("click", function addEmailClick(evt) {
|
|
|
|
this.step = 0;
|
|
|
|
}.bind(this));
|
|
|
|
|
|
|
|
this.chooseEmailLink.value = gNavigatorBundle.getString("identity.chooseIdentity.label");
|
|
|
|
this.chooseEmailLink.hidden = !("result" in identities && identities.result.length);
|
|
|
|
this.chooseEmailLink.addEventListener("click", function chooseEmailClick(evt) {
|
|
|
|
this.step = 1;
|
|
|
|
}.bind(this));
|
|
|
|
|
|
|
|
this.emailField.addEventListener("blur", function onEmailBlur() {
|
|
|
|
this.identity.typedEmail = this.emailField.value;
|
|
|
|
}.bind(this));
|
|
|
|
]]></constructor>
|
2012-06-13 01:16:00 +00:00
|
|
|
|
2013-03-27 17:01:46 +00:00
|
|
|
<field name="SignInToWebsiteUX" readonly="true">
|
|
|
|
let sitw = {};
|
|
|
|
Components.utils.import("resource:///modules/SignInToWebsite.jsm", sitw);
|
|
|
|
sitw.SignInToWebsiteUX;
|
|
|
|
</field>
|
2012-06-13 01:16:00 +00:00
|
|
|
|
2013-03-27 17:01:46 +00:00
|
|
|
<field name="newIdentityDesc" readonly="true">
|
|
|
|
document.getAnonymousElementByAttribute(this, "anonid", "newidentitydesc");
|
|
|
|
</field>
|
2012-06-13 01:16:00 +00:00
|
|
|
|
2013-03-27 17:01:46 +00:00
|
|
|
<field name="chooseIdentityDesc" readonly="true">
|
|
|
|
document.getAnonymousElementByAttribute(this, "anonid", "chooseidentitydesc");
|
|
|
|
</field>
|
2012-06-13 01:16:00 +00:00
|
|
|
|
2013-03-27 17:01:46 +00:00
|
|
|
<field name="identityList" readonly="true">
|
|
|
|
document.getAnonymousElementByAttribute(this, "anonid", "identities");
|
|
|
|
</field>
|
2012-06-13 01:16:00 +00:00
|
|
|
|
2013-03-27 17:01:46 +00:00
|
|
|
<field name="emailField" readonly="true">
|
|
|
|
document.getAnonymousElementByAttribute(this, "anonid", "email");
|
|
|
|
</field>
|
2012-06-13 01:16:00 +00:00
|
|
|
|
2013-03-27 17:01:46 +00:00
|
|
|
<field name="addEmailLink" readonly="true">
|
|
|
|
document.getAnonymousElementByAttribute(this, "anonid", "newemail");
|
|
|
|
</field>
|
|
|
|
|
|
|
|
<field name="chooseEmailLink" readonly="true">
|
|
|
|
document.getAnonymousElementByAttribute(this, "anonid", "chooseemail");
|
|
|
|
</field>
|
|
|
|
|
|
|
|
<field name="throbber" readonly="true">
|
|
|
|
document.getAnonymousElementByAttribute(this, "anonid", "throbber");
|
|
|
|
</field>
|
|
|
|
|
|
|
|
<field name="identity" readonly="true">
|
|
|
|
this.notification.options.identity;
|
|
|
|
</field>
|
|
|
|
|
|
|
|
<!-- persist the state on the identity object so we can re-create the
|
|
|
|
notification state upon re-opening -->
|
|
|
|
<property name="step">
|
|
|
|
<getter>
|
|
|
|
return this.identity.step;
|
|
|
|
</getter>
|
|
|
|
<setter><![CDATA[
|
|
|
|
let deck = document.getAnonymousElementByAttribute(this, "anonid", "identity-deck");
|
|
|
|
for (let i = 0; i < deck.children.length; i++) {
|
|
|
|
deck.children[i].hidden = (val != i);
|
|
|
|
}
|
|
|
|
this.identity.step = val;
|
|
|
|
switch (val) {
|
|
|
|
case 0:
|
|
|
|
this.emailField.focus();
|
|
|
|
break;
|
|
|
|
}]]>
|
|
|
|
</setter>
|
|
|
|
</property>
|
|
|
|
|
|
|
|
<method name="onIdentitySelected">
|
|
|
|
<body><![CDATA[
|
|
|
|
this.throbber.style.visibility = "visible";
|
|
|
|
this.button.disabled = true;
|
|
|
|
this.emailField.value = this.identity.selected
|
|
|
|
this.emailField.disabled = true;
|
|
|
|
this.identityList.disabled = true;
|
|
|
|
]]></body>
|
|
|
|
</method>
|
|
|
|
|
|
|
|
<method name="_populateLink">
|
|
|
|
<parameter name="aURL"/>
|
|
|
|
<parameter name="aLinkId"/>
|
|
|
|
<parameter name="aStringId"/>
|
|
|
|
<body><![CDATA[
|
|
|
|
if (aURL) {
|
|
|
|
// Show optional link to aURL
|
|
|
|
let link = document.getAnonymousElementByAttribute(this, "anonid", aLinkId);
|
|
|
|
link.value = gNavigatorBundle.getString(aStringId);
|
|
|
|
link.href = aURL;
|
|
|
|
link.hidden = false;
|
|
|
|
}
|
|
|
|
]]></body>
|
|
|
|
</method>
|
|
|
|
|
|
|
|
<method name="_populateIdentityList">
|
|
|
|
<parameter name="aIdentities"/>
|
|
|
|
<body><![CDATA[
|
|
|
|
let foundLastUsed = false;
|
|
|
|
let lastUsed = this.identity.selected || aIdentities.lastUsed;
|
|
|
|
for (let id in aIdentities.result) {
|
|
|
|
let label = aIdentities.result[id];
|
|
|
|
let opt = this.identityList.appendItem(label);
|
|
|
|
if (label == lastUsed) {
|
|
|
|
this.identityList.selectedItem = opt;
|
|
|
|
foundLastUsed = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!foundLastUsed) {
|
|
|
|
this.identityList.selectedIndex = -1;
|
|
|
|
}
|
|
|
|
]]></body>
|
|
|
|
</method>
|
|
|
|
|
|
|
|
<method name="_onButtonCommand">
|
|
|
|
<parameter name="aEvent"/>
|
2012-06-13 01:16:00 +00:00
|
|
|
<body><![CDATA[
|
2013-03-27 17:01:46 +00:00
|
|
|
if (aEvent.target != aEvent.currentTarget)
|
|
|
|
return;
|
|
|
|
let chosenId;
|
|
|
|
switch (this.step) {
|
|
|
|
case 0:
|
|
|
|
aEvent.stopPropagation();
|
|
|
|
if (!this.emailField.validity.valid) {
|
|
|
|
this.emailField.focus();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
chosenId = this.emailField.value;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
aEvent.stopPropagation();
|
|
|
|
let selectedItem = this.identityList.selectedItem
|
|
|
|
chosenId = selectedItem ? selectedItem.label : null;
|
|
|
|
if (!chosenId)
|
|
|
|
return;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
throw new Error("Unknown case");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
// Actually select the identity
|
|
|
|
this.SignInToWebsiteUX.selectIdentity(this.identity.rpId, chosenId);
|
|
|
|
this.identity.selected = chosenId;
|
|
|
|
this.onIdentitySelected();
|
2012-06-13 01:16:00 +00:00
|
|
|
]]></body>
|
|
|
|
</method>
|
|
|
|
|
|
|
|
</implementation>
|
|
|
|
</binding>
|
|
|
|
|
2013-06-24 12:51:07 +00:00
|
|
|
<binding id="plugin-popupnotification-center-item">
|
2012-08-28 16:23:10 +00:00
|
|
|
<content align="center">
|
2013-06-24 12:51:07 +00:00
|
|
|
<xul:vbox pack="center" anonid="itemBox" class="itemBox">
|
2013-06-24 12:51:08 +00:00
|
|
|
<xul:description anonid="center-item-label" class="center-item-label" />
|
2013-06-24 12:51:07 +00:00
|
|
|
<xul:hbox flex="1" pack="start" align="center" anonid="center-item-warning">
|
|
|
|
<xul:image anonid="center-item-warning-icon" class="center-item-warning-icon"/>
|
|
|
|
<xul:label anonid="center-item-warning-label"/>
|
|
|
|
<xul:label anonid="center-item-link" value="&checkForUpdates;" class="text-link"/>
|
2012-09-30 02:32:34 +00:00
|
|
|
</xul:hbox>
|
|
|
|
</xul:vbox>
|
2013-06-24 12:51:07 +00:00
|
|
|
<xul:vbox pack="center">
|
|
|
|
<xul:menulist class="center-item-menulist"
|
|
|
|
anonid="center-item-menulist">
|
|
|
|
<xul:menupopup>
|
|
|
|
<xul:menuitem anonid="allownow" value="allownow"
|
|
|
|
label="&pluginActivateNow.label;" />
|
|
|
|
<xul:menuitem anonid="allowalways" value="allowalways"
|
|
|
|
label="&pluginActivateAlways.label;" />
|
|
|
|
<xul:menuitem anonid="block" value="block"
|
|
|
|
label="&pluginBlockNow.label;" />
|
|
|
|
</xul:menupopup>
|
|
|
|
</xul:menulist>
|
|
|
|
</xul:vbox>
|
2012-08-28 16:23:10 +00:00
|
|
|
</content>
|
|
|
|
<resources>
|
|
|
|
<stylesheet src="chrome://global/skin/notification.css"/>
|
|
|
|
</resources>
|
|
|
|
<implementation>
|
2013-06-24 12:51:07 +00:00
|
|
|
<constructor><![CDATA[
|
|
|
|
document.getAnonymousElementByAttribute(this, "anonid", "center-item-label").value = this.action.pluginName;
|
|
|
|
|
|
|
|
let curState = "block";
|
|
|
|
if (this.action.fallbackType == Ci.nsIObjectLoadingContent.PLUGIN_ACTIVE) {
|
|
|
|
if (this.action.pluginPermissionType == Ci.nsIPermissionManager.EXPIRE_SESSION) {
|
|
|
|
curState = "allownow";
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
curState = "allowalways";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
document.getAnonymousElementByAttribute(this, "anonid", "center-item-menulist").value = curState;
|
|
|
|
|
|
|
|
let warningString = "";
|
|
|
|
let linkString = "";
|
|
|
|
|
|
|
|
let link = document.getAnonymousElementByAttribute(this, "anonid", "center-item-link");
|
|
|
|
|
|
|
|
let url;
|
|
|
|
let linkHandler;
|
|
|
|
|
|
|
|
if (this.action.pluginTag.enabledState == Ci.nsIPluginTag.STATE_DISABLED) {
|
|
|
|
document.getAnonymousElementByAttribute(this, "anonid", "center-item-menulist").hidden = true;
|
|
|
|
warningString = gNavigatorBundle.getString("pluginActivateDisabled.label");
|
|
|
|
linkString = gNavigatorBundle.getString("pluginActivateDisabled.manage");
|
|
|
|
linkHandler = function(event) {
|
|
|
|
event.preventDefault();
|
|
|
|
gPluginHandler.managePlugins();
|
|
|
|
};
|
|
|
|
document.getAnonymousElementByAttribute(this, "anonid", "center-item-warning-icon").hidden = true;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
url = this.action.detailsLink;
|
|
|
|
|
|
|
|
switch (this.action.blocklistState) {
|
|
|
|
case Ci.nsIBlocklistService.STATE_NOT_BLOCKED:
|
|
|
|
document.getAnonymousElementByAttribute(this, "anonid", "center-item-warning").hidden = true;
|
|
|
|
break;
|
|
|
|
case Ci.nsIBlocklistService.STATE_BLOCKED:
|
|
|
|
document.getAnonymousElementByAttribute(this, "anonid", "center-item-menulist").hidden = true;
|
|
|
|
warningString = gNavigatorBundle.getString("pluginActivateBlocked.label");
|
|
|
|
linkString = gNavigatorBundle.getString("pluginActivate.learnMore");
|
|
|
|
break;
|
|
|
|
case Ci.nsIBlocklistService.STATE_VULNERABLE_UPDATE_AVAILABLE:
|
|
|
|
warningString = gNavigatorBundle.getString("pluginActivateOutdated.label");
|
|
|
|
linkString = gNavigatorBundle.getString("pluginActivate.updateLabel");
|
|
|
|
break;
|
|
|
|
case Ci.nsIBlocklistService.STATE_VULNERABLE_NO_UPDATE:
|
|
|
|
warningString = gNavigatorBundle.getString("pluginActivateVulnerable.label");
|
|
|
|
linkString = gNavigatorBundle.getString("pluginActivate.riskLabel");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
document.getAnonymousElementByAttribute(this, "anonid", "center-item-warning-label").value = warningString;
|
|
|
|
|
|
|
|
if (url || linkHandler) {
|
|
|
|
link.value = linkString;
|
|
|
|
if (url) {
|
|
|
|
link.href = url;
|
|
|
|
}
|
|
|
|
if (linkHandler) {
|
|
|
|
link.addEventListener("click", linkHandler, false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
link.hidden = true;
|
|
|
|
}
|
|
|
|
]]></constructor>
|
|
|
|
<property name="value">
|
|
|
|
<getter>
|
|
|
|
return document.getAnonymousElementByAttribute(this, "anonid",
|
|
|
|
"center-item-menulist").value;
|
|
|
|
</getter>
|
2013-06-24 12:51:07 +00:00
|
|
|
<setter><!-- This should be used only in automated tests -->
|
|
|
|
document.getAnonymousElementByAttribute(this, "anonid",
|
|
|
|
"center-item-menulist").value = val;
|
|
|
|
</setter>
|
2013-06-24 12:51:07 +00:00
|
|
|
</property>
|
2012-08-28 16:23:10 +00:00
|
|
|
</implementation>
|
|
|
|
</binding>
|
|
|
|
|
|
|
|
<binding id="click-to-play-plugins-notification" extends="chrome://global/content/bindings/notification.xml#popup-notification">
|
2013-09-26 19:18:25 +00:00
|
|
|
<content align="start" style="width: &pluginNotification.width;;">
|
2013-06-24 12:51:07 +00:00
|
|
|
<xul:vbox flex="1" align="stretch" class="popup-notification-main-box"
|
|
|
|
xbl:inherits="popupid">
|
|
|
|
<xul:hbox class="click-to-play-plugins-notification-description-box" flex="1" align="start">
|
2013-06-24 12:51:08 +00:00
|
|
|
<xul:description class="click-to-play-plugins-outer-description" flex="1">
|
2013-06-24 12:51:07 +00:00
|
|
|
<html:span anonid="click-to-play-plugins-notification-description" />
|
2013-06-24 12:51:08 +00:00
|
|
|
<xul:label class="text-link click-to-play-plugins-notification-link" anonid="click-to-play-plugins-notification-link" />
|
2013-06-24 12:51:07 +00:00
|
|
|
</xul:description>
|
|
|
|
<xul:toolbarbutton anonid="closebutton"
|
|
|
|
class="messageCloseButton popup-notification-closebutton tabbable"
|
|
|
|
xbl:inherits="oncommand=closebuttoncommand"
|
|
|
|
tooltiptext="&closeNotification.tooltip;"/>
|
|
|
|
</xul:hbox>
|
2013-06-24 12:51:08 +00:00
|
|
|
<xul:grid anonid="click-to-play-plugins-notification-center-box"
|
|
|
|
class="click-to-play-plugins-notification-center-box">
|
2013-06-24 12:51:07 +00:00
|
|
|
<xul:columns>
|
|
|
|
<xul:column flex="1"/>
|
|
|
|
<xul:column/>
|
|
|
|
</xul:columns>
|
|
|
|
<xul:rows>
|
|
|
|
<children includes="row"/>
|
|
|
|
<xul:hbox pack="start" anonid="plugin-notification-showbox">
|
|
|
|
<xul:button label="&pluginNotification.showAll.label;"
|
|
|
|
accesskey="&pluginNotification.showAll.accesskey;"
|
|
|
|
class="plugin-notification-showbutton"
|
|
|
|
oncommand="document.getBindingParent(this)._setState(2)"/>
|
|
|
|
</xul:hbox>
|
|
|
|
</xul:rows>
|
|
|
|
</xul:grid>
|
|
|
|
<xul:hbox anonid="button-container"
|
|
|
|
class="click-to-play-plugins-notification-button-container"
|
|
|
|
pack="center" align="center">
|
|
|
|
<xul:button anonid="primarybutton"
|
2013-06-26 13:56:12 +00:00
|
|
|
class="click-to-play-popup-button"
|
2013-06-24 12:51:08 +00:00
|
|
|
oncommand="document.getBindingParent(this)._onButton(this)"
|
|
|
|
flex="1"/>
|
2013-06-24 12:51:07 +00:00
|
|
|
<xul:button anonid="secondarybutton"
|
2013-06-24 12:51:08 +00:00
|
|
|
class="click-to-play-popup-button"
|
|
|
|
oncommand="document.getBindingParent(this)._onButton(this);"
|
|
|
|
flex="1"/>
|
2013-06-24 12:51:07 +00:00
|
|
|
</xul:hbox>
|
|
|
|
<xul:box hidden="true">
|
|
|
|
<children/>
|
|
|
|
</xul:box>
|
|
|
|
</xul:vbox>
|
2012-08-28 16:23:10 +00:00
|
|
|
</content>
|
|
|
|
<resources>
|
|
|
|
<stylesheet src="chrome://global/skin/notification.css"/>
|
|
|
|
</resources>
|
|
|
|
<implementation>
|
2013-06-24 12:51:07 +00:00
|
|
|
<field name="_states">
|
|
|
|
({SINGLE: 0, MULTI_COLLAPSED: 1, MULTI_EXPANDED: 2})
|
|
|
|
</field>
|
|
|
|
<field name="_primaryButton">
|
|
|
|
document.getAnonymousElementByAttribute(this, "anonid", "primarybutton");
|
|
|
|
</field>
|
|
|
|
<field name="_secondaryButton">
|
|
|
|
document.getAnonymousElementByAttribute(this, "anonid", "secondarybutton")
|
2012-08-28 16:23:10 +00:00
|
|
|
</field>
|
2013-06-24 12:51:07 +00:00
|
|
|
<field name="_buttonContainer">
|
|
|
|
document.getAnonymousElementByAttribute(this, "anonid", "button-container")
|
2012-08-28 16:23:10 +00:00
|
|
|
</field>
|
2013-06-24 12:51:07 +00:00
|
|
|
<field name="_brandShortName">
|
|
|
|
document.getElementById("bundle_brand").getString("brandShortName")
|
|
|
|
</field>
|
|
|
|
<field name="_items">[]</field>
|
2012-08-28 16:23:10 +00:00
|
|
|
<constructor><![CDATA[
|
|
|
|
const XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
|
2013-06-24 12:51:07 +00:00
|
|
|
for (let action of this.notification.options.centerActions) {
|
|
|
|
let item = document.createElementNS(XUL_NS, "row");
|
|
|
|
item.setAttribute("class", "plugin-popupnotification-centeritem");
|
2012-08-28 16:23:10 +00:00
|
|
|
item.action = action;
|
2013-06-24 12:51:07 +00:00
|
|
|
this.appendChild(item);
|
|
|
|
this._items.push(item);
|
|
|
|
}
|
2013-07-19 14:02:48 +00:00
|
|
|
switch (this.notification.options.centerActions.length) {
|
|
|
|
case 0:
|
|
|
|
PopupNotifications._dismiss();
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
this._setState(this._states.SINGLE);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
if (this.notification.options.primaryPlugin) {
|
|
|
|
this._setState(this._states.MULTI_COLLAPSED);
|
|
|
|
} else {
|
|
|
|
this._setState(this._states.MULTI_EXPANDED);
|
|
|
|
}
|
2012-08-28 16:23:10 +00:00
|
|
|
}
|
|
|
|
]]></constructor>
|
2013-06-24 12:51:07 +00:00
|
|
|
<method name="_setState">
|
|
|
|
<parameter name="state" />
|
|
|
|
<body><![CDATA[
|
|
|
|
var grid = document.getAnonymousElementByAttribute(this, "anonid", "click-to-play-plugins-notification-center-box");
|
|
|
|
|
|
|
|
if (this._states.SINGLE == state) {
|
|
|
|
grid.hidden = true;
|
|
|
|
this._setupSingleState();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-07-03 13:01:06 +00:00
|
|
|
let host = gPluginHandler._getHostFromPrincipal(this.notification.browser.contentWindow.document.nodePrincipal);
|
|
|
|
this._setupDescription("pluginActivateMultiple.message", null, host);
|
2013-06-24 12:51:07 +00:00
|
|
|
|
|
|
|
var showBox = document.getAnonymousElementByAttribute(this, "anonid", "plugin-notification-showbox");
|
|
|
|
|
|
|
|
var dialogStrings = Services.strings.createBundle("chrome://global/locale/dialog.properties");
|
|
|
|
this._primaryButton.label = dialogStrings.GetStringFromName("button-accept");
|
|
|
|
this._primaryButton.setAttribute("default", "true");
|
|
|
|
|
|
|
|
this._secondaryButton.label = dialogStrings.GetStringFromName("button-cancel");
|
|
|
|
this._primaryButton.setAttribute("action", "_multiAccept");
|
|
|
|
this._secondaryButton.setAttribute("action", "_cancel");
|
|
|
|
|
|
|
|
grid.hidden = false;
|
|
|
|
|
|
|
|
if (this._states.MULTI_COLLAPSED == state) {
|
|
|
|
for (let child of this.childNodes) {
|
|
|
|
if (child.tagName != "row") {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
child.hidden = this.notification.options.primaryPlugin !=
|
|
|
|
child.action.permissionString;
|
|
|
|
}
|
|
|
|
showBox.hidden = false;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
for (let child of this.childNodes) {
|
|
|
|
if (child.tagName != "row") {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
child.hidden = false;
|
|
|
|
}
|
|
|
|
showBox.hidden = true;
|
|
|
|
}
|
|
|
|
this._setupLink(null);
|
|
|
|
]]></body>
|
|
|
|
</method>
|
|
|
|
<method name="_setupSingleState">
|
|
|
|
<body><![CDATA[
|
|
|
|
var action = this.notification.options.centerActions[0];
|
|
|
|
var host = action.pluginPermissionHost;
|
|
|
|
|
|
|
|
let label, linkLabel, linkUrl, button1, button2;
|
|
|
|
|
|
|
|
if (action.fallbackType == Ci.nsIObjectLoadingContent.PLUGIN_ACTIVE) {
|
|
|
|
button1 = {
|
|
|
|
label: "pluginBlockNow.label",
|
|
|
|
accesskey: "pluginBlockNow.accesskey",
|
|
|
|
action: "_singleBlock"
|
|
|
|
};
|
|
|
|
button2 = {
|
|
|
|
label: "pluginContinue.label",
|
|
|
|
accesskey: "pluginContinue.accesskey",
|
2013-07-19 14:02:48 +00:00
|
|
|
action: "_singleContinue",
|
2013-06-24 12:51:07 +00:00
|
|
|
default: true
|
|
|
|
};
|
|
|
|
switch (action.blocklistState) {
|
|
|
|
case Ci.nsIBlocklistService.STATE_NOT_BLOCKED:
|
|
|
|
label = "pluginEnabled.message";
|
|
|
|
linkLabel = "pluginActivate.learnMore";
|
|
|
|
break;
|
|
|
|
|
|
|
|
case Ci.nsIBlocklistService.STATE_BLOCKED:
|
|
|
|
Cu.reportError(Error("Cannot happen!"));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case Ci.nsIBlocklistService.STATE_VULNERABLE_UPDATE_AVAILABLE:
|
|
|
|
label = "pluginEnabledOutdated.message";
|
|
|
|
linkLabel = "pluginActivate.updateLabel";
|
|
|
|
break;
|
|
|
|
|
|
|
|
case Ci.nsIBlocklistService.STATE_VULNERABLE_NO_UPDATE:
|
|
|
|
label = "pluginEnabledVulnerable.message";
|
|
|
|
linkLabel = "pluginActivate.riskLabel"
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
Cu.reportError(Error("Unexpected blocklist state"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (action.pluginTag.enabledState == Ci.nsIPluginTag.STATE_DISABLED) {
|
|
|
|
let linkElement =
|
|
|
|
document.getAnonymousElementByAttribute(
|
|
|
|
this, "anonid", "click-to-play-plugins-notification-link");
|
2013-06-24 12:51:08 +00:00
|
|
|
linkElement.textContent = gNavigatorBundle.getString("pluginActivateDisabled.manage");
|
2013-06-24 12:51:07 +00:00
|
|
|
linkElement.setAttribute("onclick", "gPluginHandler.managePlugins()");
|
|
|
|
|
|
|
|
let descElement = document.getAnonymousElementByAttribute(this, "anonid", "click-to-play-plugins-notification-description");
|
|
|
|
descElement.textContent = gNavigatorBundle.getFormattedString(
|
2013-06-24 12:51:08 +00:00
|
|
|
"pluginActivateDisabled.message", [action.pluginName, this._brandShortName]) + " ";
|
2013-06-24 12:51:07 +00:00
|
|
|
this._buttonContainer.hidden = true;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else if (action.blocklistState == Ci.nsIBlocklistService.STATE_BLOCKED) {
|
|
|
|
let descElement = document.getAnonymousElementByAttribute(this, "anonid", "click-to-play-plugins-notification-description");
|
|
|
|
descElement.textContent = gNavigatorBundle.getFormattedString(
|
2013-06-24 12:51:08 +00:00
|
|
|
"pluginActivateBlocked.message", [action.pluginName, this._brandShortName]) + " ";
|
2013-06-24 12:51:07 +00:00
|
|
|
this._setupLink("pluginActivate.learnMore", action.detailsLink);
|
|
|
|
this._buttonContainer.hidden = true;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
button1 = {
|
|
|
|
label: "pluginActivateNow.label",
|
|
|
|
accesskey: "pluginActivateNow.accesskey",
|
|
|
|
action: "_singleActivateNow"
|
|
|
|
};
|
|
|
|
button2 = {
|
|
|
|
label: "pluginActivateAlways.label",
|
|
|
|
accesskey: "pluginActivateAlways.accesskey",
|
|
|
|
action: "_singleActivateAlways"
|
|
|
|
};
|
|
|
|
switch (action.blocklistState) {
|
|
|
|
case Ci.nsIBlocklistService.STATE_NOT_BLOCKED:
|
|
|
|
label = "pluginActivateNew.message";
|
|
|
|
linkLabel = "pluginActivate.learnMore";
|
|
|
|
button2.default = true;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case Ci.nsIBlocklistService.STATE_VULNERABLE_UPDATE_AVAILABLE:
|
2013-06-28 22:42:04 +00:00
|
|
|
label = "pluginActivateOutdated.message";
|
2013-06-24 12:51:07 +00:00
|
|
|
linkLabel = "pluginActivate.updateLabel";
|
|
|
|
button1.default = true;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case Ci.nsIBlocklistService.STATE_VULNERABLE_NO_UPDATE:
|
|
|
|
label = "pluginActivateVulnerable.message";
|
|
|
|
linkLabel = "pluginActivate.riskLabel"
|
|
|
|
button1.default = true;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
Cu.reportError(Error("Unexpected blocklist state"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
this._setupDescription(label, action.pluginName, host);
|
|
|
|
this._setupLink(linkLabel, action.detailsLink);
|
|
|
|
|
|
|
|
this._primaryButton.label = gNavigatorBundle.getString(button1.label);
|
|
|
|
this._primaryButton.accesskey = gNavigatorBundle.getString(button1.accesskey);
|
|
|
|
this._primaryButton.setAttribute("action", button1.action);
|
|
|
|
|
|
|
|
this._secondaryButton.label = gNavigatorBundle.getString(button2.label);
|
|
|
|
this._secondaryButton.accesskey = gNavigatorBundle.getString(button2.accesskey);
|
|
|
|
this._secondaryButton.setAttribute("action", button2.action);
|
|
|
|
if (button1.default) {
|
|
|
|
this._primaryButton.setAttribute("default", "true");
|
|
|
|
}
|
|
|
|
else if (button2.default) {
|
|
|
|
this._secondaryButton.setAttribute("default", "true");
|
|
|
|
}
|
|
|
|
]]></body>
|
|
|
|
</method>
|
|
|
|
<method name="_setupDescription">
|
|
|
|
<parameter name="baseString" />
|
|
|
|
<parameter name="pluginName" /> <!-- null for the multiple-plugin case -->
|
|
|
|
<parameter name="host" />
|
|
|
|
<body><![CDATA[
|
|
|
|
var bsn = this._brandShortName;
|
|
|
|
var span = document.getAnonymousElementByAttribute(this, "anonid", "click-to-play-plugins-notification-description");
|
|
|
|
while (span.lastChild) {
|
|
|
|
span.removeChild(span.lastChild);
|
|
|
|
}
|
|
|
|
|
|
|
|
var args = ["__host__", this._brandShortName];
|
|
|
|
if (pluginName) {
|
|
|
|
args.unshift(pluginName);
|
|
|
|
}
|
|
|
|
var bases = gNavigatorBundle.getFormattedString(baseString, args).
|
|
|
|
split("__host__", 2);
|
|
|
|
|
|
|
|
span.appendChild(document.createTextNode(bases[0]));
|
|
|
|
var hostSpan = document.createElementNS("http://www.w3.org/1999/xhtml", "em");
|
|
|
|
hostSpan.appendChild(document.createTextNode(host));
|
|
|
|
span.appendChild(hostSpan);
|
2013-06-24 12:51:08 +00:00
|
|
|
span.appendChild(document.createTextNode(bases[1] + " "));
|
2013-06-24 12:51:07 +00:00
|
|
|
]]></body>
|
|
|
|
</method>
|
|
|
|
<method name="_setupLink">
|
|
|
|
<parameter name="linkString"/>
|
|
|
|
<parameter name="linkUrl" />
|
|
|
|
<body><![CDATA[
|
|
|
|
var link = document.getAnonymousElementByAttribute(this, "anonid", "click-to-play-plugins-notification-link");
|
|
|
|
if (!linkString || !linkUrl) {
|
|
|
|
link.hidden = true;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
link.hidden = false;
|
2013-06-24 12:51:08 +00:00
|
|
|
link.textContent = gNavigatorBundle.getString(linkString);
|
2013-06-24 12:51:07 +00:00
|
|
|
link.href = linkUrl;
|
|
|
|
]]></body>
|
|
|
|
</method>
|
|
|
|
<method name="_onButton">
|
|
|
|
<parameter name="aButton" />
|
|
|
|
<body><![CDATA[
|
|
|
|
let methodName = aButton.getAttribute("action");
|
|
|
|
this[methodName]();
|
|
|
|
]]></body>
|
|
|
|
</method>
|
|
|
|
<method name="_singleActivateNow">
|
|
|
|
<body><![CDATA[
|
|
|
|
gPluginHandler._updatePluginPermission(this.notification,
|
|
|
|
this.notification.options.centerActions[0],
|
|
|
|
"allownow");
|
|
|
|
this._cancel();
|
|
|
|
]]></body>
|
|
|
|
</method>
|
|
|
|
<method name="_singleBlock">
|
|
|
|
<body><![CDATA[
|
|
|
|
gPluginHandler._updatePluginPermission(this.notification,
|
|
|
|
this.notification.options.centerActions[0],
|
|
|
|
"block");
|
|
|
|
this._cancel();
|
|
|
|
]]></body>
|
|
|
|
</method>
|
|
|
|
<method name="_singleActivateAlways">
|
|
|
|
<body><![CDATA[
|
|
|
|
gPluginHandler._updatePluginPermission(this.notification,
|
|
|
|
this.notification.options.centerActions[0],
|
|
|
|
"allowalways");
|
|
|
|
this._cancel();
|
|
|
|
]]></body>
|
|
|
|
</method>
|
2013-07-19 14:02:48 +00:00
|
|
|
<method name="_singleContinue">
|
|
|
|
<body><![CDATA[
|
|
|
|
gPluginHandler._updatePluginPermission(this.notification,
|
|
|
|
this.notification.options.centerActions[0],
|
|
|
|
"continue");
|
|
|
|
this._cancel();
|
|
|
|
]]></body>
|
|
|
|
</method>
|
2013-06-24 12:51:07 +00:00
|
|
|
<method name="_multiAccept">
|
|
|
|
<body><![CDATA[
|
|
|
|
for (let item of this._items) {
|
|
|
|
let action = item.action;
|
|
|
|
if (action.pluginTag.enabledState == Ci.nsIPluginTag.STATE_DISABLED ||
|
|
|
|
action.blocklistState == Ci.nsIBlocklistService.STATE_BLOCKED) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
gPluginHandler._updatePluginPermission(this.notification,
|
|
|
|
item.action, item.value);
|
|
|
|
}
|
|
|
|
this._cancel();
|
|
|
|
]]></body>
|
|
|
|
</method>
|
|
|
|
<method name="_cancel">
|
|
|
|
<body><![CDATA[
|
|
|
|
PopupNotifications._dismiss();
|
|
|
|
]]></body>
|
|
|
|
</method>
|
|
|
|
<method name="_accept">
|
|
|
|
<parameter name="aEvent" />
|
|
|
|
<body><![CDATA[
|
|
|
|
if (aEvent.defaultPrevented)
|
|
|
|
return;
|
|
|
|
aEvent.preventDefault();
|
|
|
|
if (this._primaryButton.getAttribute("default") == "true") {
|
|
|
|
this._primaryButton.click();
|
|
|
|
}
|
|
|
|
else if (this._secondaryButton.getAttribute("default") == "true") {
|
|
|
|
this._secondaryButton.click();
|
|
|
|
}
|
|
|
|
]]></body>
|
|
|
|
</method>
|
2012-08-28 16:23:10 +00:00
|
|
|
</implementation>
|
2013-06-24 12:51:07 +00:00
|
|
|
<handlers>
|
|
|
|
<!-- The _accept method checks for .defaultPrevented so that if focus is in a button,
|
|
|
|
enter activates the button and not this default action -->
|
|
|
|
<handler event="keypress" keycode="VK_ENTER" group="system" action="this._accept(event);"/>
|
|
|
|
<handler event="keypress" keycode="VK_RETURN" group="system" action="this._accept(event);"/>
|
|
|
|
</handlers>
|
2012-08-28 16:23:10 +00:00
|
|
|
</binding>
|
2012-06-13 01:16:00 +00:00
|
|
|
|
2011-01-11 10:59:42 +00:00
|
|
|
<binding id="splitmenu">
|
|
|
|
<content>
|
2011-01-22 11:21:53 +00:00
|
|
|
<xul:hbox anonid="menuitem" flex="1"
|
|
|
|
class="splitmenu-menuitem"
|
|
|
|
xbl:inherits="iconic,label,disabled,onclick=oncommand,_moz-menuactive=active"/>
|
|
|
|
<xul:menu anonid="menu" class="splitmenu-menu"
|
2011-02-16 15:53:32 +00:00
|
|
|
xbl:inherits="disabled,_moz-menuactive=active"
|
2011-01-11 10:59:42 +00:00
|
|
|
oncommand="event.stopPropagation();">
|
|
|
|
<children includes="menupopup"/>
|
|
|
|
</xul:menu>
|
|
|
|
</content>
|
|
|
|
|
2011-03-02 18:47:03 +00:00
|
|
|
<implementation implements="nsIDOMEventListener">
|
|
|
|
<constructor><![CDATA[
|
|
|
|
this._parentMenupopup.addEventListener("DOMMenuItemActive", this, false);
|
|
|
|
this._parentMenupopup.addEventListener("popuphidden", this, false);
|
|
|
|
]]></constructor>
|
|
|
|
|
|
|
|
<destructor><![CDATA[
|
|
|
|
this._parentMenupopup.removeEventListener("DOMMenuItemActive", this, false);
|
|
|
|
this._parentMenupopup.removeEventListener("popuphidden", this, false);
|
|
|
|
]]></destructor>
|
|
|
|
|
2011-01-22 11:21:53 +00:00
|
|
|
<field name="menuitem" readonly="true">
|
|
|
|
document.getAnonymousElementByAttribute(this, "anonid", "menuitem");
|
|
|
|
</field>
|
|
|
|
<field name="menu" readonly="true">
|
|
|
|
document.getAnonymousElementByAttribute(this, "anonid", "menu");
|
2011-01-11 10:59:42 +00:00
|
|
|
</field>
|
2011-01-22 11:21:53 +00:00
|
|
|
|
|
|
|
<field name="_menuDelay">600</field>
|
|
|
|
|
|
|
|
<field name="_parentMenupopup"><![CDATA[
|
2011-03-02 18:47:03 +00:00
|
|
|
this._getParentMenupopup(this);
|
2011-01-22 11:21:53 +00:00
|
|
|
]]></field>
|
2011-03-02 18:47:03 +00:00
|
|
|
|
|
|
|
<method name="_getParentMenupopup">
|
|
|
|
<parameter name="aNode"/>
|
|
|
|
<body><![CDATA[
|
|
|
|
let node = aNode.parentNode;
|
|
|
|
while (node) {
|
|
|
|
if (node.localName == "menupopup")
|
|
|
|
break;
|
|
|
|
node = node.parentNode;
|
|
|
|
}
|
|
|
|
return node;
|
|
|
|
]]></body>
|
|
|
|
</method>
|
|
|
|
|
|
|
|
<method name="handleEvent">
|
|
|
|
<parameter name="event"/>
|
|
|
|
<body><![CDATA[
|
|
|
|
switch (event.type) {
|
|
|
|
case "DOMMenuItemActive":
|
|
|
|
if (this.getAttribute("active") == "true" &&
|
|
|
|
event.target != this &&
|
|
|
|
this._getParentMenupopup(event.target) == this._parentMenupopup)
|
|
|
|
this.removeAttribute("active");
|
|
|
|
break;
|
|
|
|
case "popuphidden":
|
|
|
|
if (event.target == this._parentMenupopup)
|
|
|
|
this.removeAttribute("active");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
]]></body>
|
|
|
|
</method>
|
2011-01-11 10:59:42 +00:00
|
|
|
</implementation>
|
2011-01-22 11:21:53 +00:00
|
|
|
|
|
|
|
<handlers>
|
|
|
|
<handler event="mouseover"><![CDATA[
|
2011-03-23 11:36:13 +00:00
|
|
|
if (this.getAttribute("active") != "true") {
|
2011-01-22 11:21:53 +00:00
|
|
|
this.setAttribute("active", "true");
|
|
|
|
|
2011-03-02 18:47:03 +00:00
|
|
|
let event = document.createEvent("Events");
|
|
|
|
event.initEvent("DOMMenuItemActive", true, false);
|
|
|
|
this.dispatchEvent(event);
|
|
|
|
|
2011-03-23 11:36:13 +00:00
|
|
|
if (this.getAttribute("disabled") != "true") {
|
|
|
|
let self = this;
|
|
|
|
setTimeout(function () {
|
|
|
|
if (self.getAttribute("active") == "true")
|
|
|
|
self.menu.open = true;
|
|
|
|
}, this._menuDelay);
|
|
|
|
}
|
2011-01-22 11:21:53 +00:00
|
|
|
}
|
|
|
|
]]></handler>
|
|
|
|
|
2011-01-26 18:54:14 +00:00
|
|
|
<handler event="popupshowing"><![CDATA[
|
|
|
|
if (event.target == this.firstChild &&
|
|
|
|
this._parentMenupopup._currentPopup)
|
|
|
|
this._parentMenupopup._currentPopup.hidePopup();
|
|
|
|
]]></handler>
|
|
|
|
|
2011-01-22 11:21:53 +00:00
|
|
|
<handler event="click" phase="capturing"><![CDATA[
|
2011-03-03 10:34:55 +00:00
|
|
|
if (this.getAttribute("disabled") == "true") {
|
|
|
|
// Prevent the command from being carried out
|
|
|
|
event.stopPropagation();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-01-22 11:21:53 +00:00
|
|
|
let node = event.originalTarget;
|
|
|
|
while (true) {
|
|
|
|
if (node == this.menuitem)
|
|
|
|
break;
|
|
|
|
if (node == this)
|
|
|
|
return;
|
|
|
|
node = node.parentNode;
|
|
|
|
}
|
|
|
|
|
|
|
|
this._parentMenupopup.hidePopup();
|
|
|
|
]]></handler>
|
|
|
|
</handlers>
|
2011-01-11 10:59:42 +00:00
|
|
|
</binding>
|
2010-09-07 20:37:04 +00:00
|
|
|
|
|
|
|
<binding id="menuitem-tooltip" extends="chrome://global/content/bindings/menu.xml#menuitem">
|
|
|
|
<implementation>
|
|
|
|
<constructor><![CDATA[
|
|
|
|
this.setAttribute("tooltiptext", this.getAttribute("acceltext"));
|
|
|
|
// TODO: Simplify this to this.setAttribute("acceltext", "") once bug
|
|
|
|
// 592424 is fixed
|
|
|
|
document.getAnonymousElementByAttribute(this, "anonid", "accel").firstChild.setAttribute("value", "");
|
|
|
|
]]></constructor>
|
|
|
|
</implementation>
|
|
|
|
</binding>
|
|
|
|
|
|
|
|
<binding id="menuitem-iconic-tooltip" extends="chrome://global/content/bindings/menu.xml#menuitem-iconic">
|
|
|
|
<implementation>
|
|
|
|
<constructor><![CDATA[
|
|
|
|
this.setAttribute("tooltiptext", this.getAttribute("acceltext"));
|
|
|
|
// TODO: Simplify this to this.setAttribute("acceltext", "") once bug
|
|
|
|
// 592424 is fixed
|
|
|
|
document.getAnonymousElementByAttribute(this, "anonid", "accel").firstChild.setAttribute("value", "");
|
|
|
|
]]></constructor>
|
|
|
|
</implementation>
|
|
|
|
</binding>
|
2011-01-22 11:21:53 +00:00
|
|
|
|
2011-05-24 04:16:39 +00:00
|
|
|
<binding id="promobox">
|
|
|
|
<content>
|
|
|
|
<xul:hbox class="panel-promo-box" align="start" flex="1">
|
|
|
|
<xul:hbox align="center" flex="1">
|
|
|
|
<xul:image class="panel-promo-icon"/>
|
|
|
|
<xul:description anonid="promo-message" class="panel-promo-message" flex="1">
|
2011-06-23 12:35:11 +00:00
|
|
|
<xul:description anonid="promo-link"
|
|
|
|
class="plain text-link inline-link"
|
|
|
|
onclick="document.getBindingParent(this).onLinkClick();"/>
|
2011-05-24 04:16:39 +00:00
|
|
|
</xul:description>
|
|
|
|
</xul:hbox>
|
|
|
|
<xul:toolbarbutton class="panel-promo-closebutton"
|
|
|
|
oncommand="document.getBindingParent(this).onCloseButtonCommand();"
|
|
|
|
tooltiptext="&closeNotification.tooltip;"/>
|
|
|
|
</xul:hbox>
|
|
|
|
</content>
|
|
|
|
|
|
|
|
<implementation implements="nsIDOMEventListener">
|
|
|
|
<constructor><![CDATA[
|
|
|
|
this._panel.addEventListener("popupshowing", this, false);
|
|
|
|
]]></constructor>
|
|
|
|
|
|
|
|
<destructor><![CDATA[
|
|
|
|
this._panel.removeEventListener("popupshowing", this, false);
|
|
|
|
]]></destructor>
|
|
|
|
|
|
|
|
<field name="_panel" readonly="true"><![CDATA[
|
|
|
|
let node = this.parentNode;
|
|
|
|
while(node && node.localName != "panel") {
|
|
|
|
node = node.parentNode;
|
|
|
|
}
|
|
|
|
node;
|
|
|
|
]]></field>
|
|
|
|
<field name="_promomessage" readonly="true">
|
|
|
|
document.getAnonymousElementByAttribute(this, "anonid", "promo-message");
|
|
|
|
</field>
|
|
|
|
<field name="_promolink" readonly="true">
|
|
|
|
document.getAnonymousElementByAttribute(this, "anonid", "promo-link");
|
|
|
|
</field>
|
|
|
|
<field name="_brandBundle" readonly="true">
|
|
|
|
Services.strings.createBundle("chrome://branding/locale/brand.properties");
|
|
|
|
</field>
|
2012-10-11 09:48:33 +00:00
|
|
|
<property name="_viewsLeftMap">
|
2012-09-16 21:38:57 +00:00
|
|
|
<getter><![CDATA[
|
2012-10-11 09:48:33 +00:00
|
|
|
let viewsLeftMap = {};
|
2012-09-16 23:18:13 +00:00
|
|
|
try {
|
2012-10-11 09:48:33 +00:00
|
|
|
viewsLeftMap = JSON.parse(Services.prefs.getCharPref("browser.syncPromoViewsLeftMap"));
|
|
|
|
} catch (ex) {
|
|
|
|
// If the old preference exists, migrate it to the new one.
|
|
|
|
try {
|
|
|
|
let oldPref = Services.prefs.getIntPref("browser.syncPromoViewsLeft");
|
|
|
|
Services.prefs.clearUserPref("browser.syncPromoViewsLeft");
|
|
|
|
viewsLeftMap.bookmarks = oldPref;
|
|
|
|
viewsLeftMap.passwords = oldPref;
|
|
|
|
Services.prefs.setCharPref("browser.syncPromoViewsLeftMap",
|
|
|
|
JSON.stringify(viewsLeftMap));
|
|
|
|
} catch (ex2) {}
|
|
|
|
}
|
|
|
|
return viewsLeftMap;
|
|
|
|
]]></getter>
|
|
|
|
</property>
|
|
|
|
<property name="_viewsLeft">
|
|
|
|
<getter><![CDATA[
|
|
|
|
let views = 5;
|
|
|
|
let map = this._viewsLeftMap;
|
|
|
|
if (this._notificationType in map) {
|
|
|
|
views = map[this._notificationType];
|
|
|
|
}
|
|
|
|
return views;
|
2011-05-24 04:16:39 +00:00
|
|
|
]]></getter>
|
|
|
|
<setter><![CDATA[
|
2012-10-11 09:48:33 +00:00
|
|
|
let map = this._viewsLeftMap;
|
|
|
|
map[this._notificationType] = val;
|
|
|
|
Services.prefs.setCharPref("browser.syncPromoViewsLeftMap",
|
|
|
|
JSON.stringify(map));
|
2011-05-24 04:16:39 +00:00
|
|
|
return val;
|
|
|
|
]]></setter>
|
|
|
|
</property>
|
|
|
|
<property name="_notificationType">
|
|
|
|
<getter><![CDATA[
|
|
|
|
// Use the popupid attribute to identify the notification type,
|
|
|
|
// otherwise just rely on the panel id for common arrowpanels.
|
|
|
|
let type = this._panel.firstChild.getAttribute("popupid") ||
|
|
|
|
this._panel.id;
|
2012-09-23 19:09:29 +00:00
|
|
|
if (type.startsWith("password-"))
|
2011-05-24 04:16:39 +00:00
|
|
|
return "passwords";
|
|
|
|
if (type == "editBookmarkPanel")
|
|
|
|
return "bookmarks";
|
2012-09-15 22:06:34 +00:00
|
|
|
if (type == "addon-install-complete") {
|
|
|
|
if (!Services.prefs.prefHasUserValue("services.sync.username"))
|
|
|
|
return "addons";
|
|
|
|
if (!Services.prefs.getBoolPref("services.sync.engine.addons"))
|
|
|
|
return "addons-sync-disabled";
|
|
|
|
}
|
2011-05-24 04:16:39 +00:00
|
|
|
return null;
|
|
|
|
]]></getter>
|
|
|
|
</property>
|
|
|
|
<property name="_notificationMessage">
|
|
|
|
<getter><![CDATA[
|
|
|
|
return gNavigatorBundle.getFormattedString(
|
2011-06-23 12:35:11 +00:00
|
|
|
"syncPromoNotification." + this._notificationType + ".description",
|
2011-05-24 04:16:39 +00:00
|
|
|
[this._brandBundle.GetStringFromName("syncBrandShortName")]
|
|
|
|
);
|
|
|
|
]]></getter>
|
|
|
|
</property>
|
2012-09-15 22:06:34 +00:00
|
|
|
<property name="_notificationLink">
|
|
|
|
<getter><![CDATA[
|
|
|
|
if (this._notificationType == "addons-sync-disabled") {
|
|
|
|
return "https://support.mozilla.org/kb/how-do-i-enable-add-sync";
|
|
|
|
}
|
|
|
|
return "https://services.mozilla.com/sync/";
|
|
|
|
]]></getter>
|
|
|
|
</property>
|
2011-05-24 04:16:39 +00:00
|
|
|
<method name="onCloseButtonCommand">
|
|
|
|
<body><![CDATA[
|
|
|
|
this._viewsLeft = 0;
|
|
|
|
this.hidden = true;
|
|
|
|
]]></body>
|
|
|
|
</method>
|
2011-06-02 14:30:56 +00:00
|
|
|
<method name="onLinkClick">
|
|
|
|
<body><![CDATA[
|
|
|
|
// Open a new selected tab and close the current panel.
|
2013-09-26 09:16:46 +00:00
|
|
|
openUILinkIn(this._promolink.getAttribute("href"), "tab");
|
2011-06-02 14:30:56 +00:00
|
|
|
this._panel.hidePopup();
|
|
|
|
]]></body>
|
|
|
|
</method>
|
2011-05-24 04:16:39 +00:00
|
|
|
<method name="handleEvent">
|
|
|
|
<parameter name="event"/>
|
|
|
|
<body><![CDATA[
|
|
|
|
if (event.type != "popupshowing" || event.target != this._panel)
|
|
|
|
return;
|
|
|
|
|
|
|
|
// A previous notification may have unhidden this.
|
|
|
|
this.hidden = true;
|
|
|
|
|
|
|
|
// Only handle supported notification panels.
|
|
|
|
if (!this._notificationType) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
let viewsLeft = this._viewsLeft;
|
|
|
|
if (viewsLeft) {
|
2012-09-15 22:06:34 +00:00
|
|
|
if (Services.prefs.prefHasUserValue("services.sync.username") &&
|
|
|
|
this._notificationType != "addons-sync-disabled") {
|
2011-05-24 04:16:39 +00:00
|
|
|
// If the user has already setup Sync, don't show the notification.
|
|
|
|
this._viewsLeft = 0;
|
|
|
|
// Be sure to hide the panel, in case it was visible and the user
|
|
|
|
// decided to setup Sync after noticing it.
|
|
|
|
viewsLeft = 0;
|
|
|
|
// The panel is still hidden, just bail out.
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
this._viewsLeft = viewsLeft - 1;
|
|
|
|
}
|
|
|
|
|
2012-09-15 22:06:34 +00:00
|
|
|
this._promolink.setAttribute("href", this._notificationLink);
|
2011-05-24 04:16:39 +00:00
|
|
|
this._promolink.value = gNavigatorBundle.getString("syncPromoNotification.learnMoreLinkText");
|
|
|
|
|
|
|
|
this.hidden = false;
|
|
|
|
|
|
|
|
// HACK: The description element doesn't wrap correctly in panels,
|
|
|
|
// thus set a width on it, based on the available space, before
|
2011-06-23 12:35:11 +00:00
|
|
|
// setting its textContent. Then set its height as well, to
|
|
|
|
// fix wrong height calculation on Linux (bug 659578).
|
2012-10-11 09:48:33 +00:00
|
|
|
this._panel.addEventListener("popupshown", function panelShown() {
|
|
|
|
this._panel.removeEventListener("popupshown", panelShown, true);
|
|
|
|
// Previous popupShown events may close the panel or change
|
|
|
|
// its contents, so ensure this is still valid.
|
|
|
|
if (this._panel.state != "open" || !this._notificationType)
|
|
|
|
return;
|
|
|
|
this._promomessage.width = this._promomessage.getBoundingClientRect().width;
|
|
|
|
this._promomessage.firstChild.textContent = this._notificationMessage;
|
|
|
|
this._promomessage.height = this._promomessage.getBoundingClientRect().height;
|
|
|
|
}.bind(this), true);
|
2011-05-24 04:16:39 +00:00
|
|
|
}
|
|
|
|
]]></body>
|
|
|
|
</method>
|
|
|
|
</implementation>
|
|
|
|
</binding>
|
|
|
|
|
2013-04-08 06:53:41 +00:00
|
|
|
<binding id="toolbarbutton-badged" display="xul:button"
|
|
|
|
extends="chrome://global/content/bindings/toolbarbutton.xml#toolbarbutton">
|
|
|
|
<content>
|
|
|
|
<children includes="observes|template|menupopup|panel|tooltip"/>
|
|
|
|
<xul:hbox class="toolbarbutton-badge-container" align="start" pack="end" flex="1">
|
|
|
|
<xul:hbox class="toolbarbutton-badge" xbl:inherits="badge"/>
|
|
|
|
<xul:image class="toolbarbutton-icon" xbl:inherits="validate,src=image,label"/>
|
|
|
|
</xul:hbox>
|
|
|
|
<xul:label class="toolbarbutton-text" crop="right" flex="1"
|
|
|
|
xbl:inherits="value=label,accesskey,crop"/>
|
|
|
|
</content>
|
|
|
|
</binding>
|
|
|
|
|
2007-06-05 04:51:15 +00:00
|
|
|
</bindings>
|