зеркало из https://github.com/mozilla/gecko-dev.git
Merge mobile-browser -> mobile2
This commit is contained in:
Коммит
8dcce6af2c
|
@ -487,3 +487,7 @@ pref("network.buffer.cache.size", 16384);
|
|||
pref("services.sync.client.type", "mobile");
|
||||
pref("services.sync.registerEngines", "Tab,Bookmarks,Form,History,Password");
|
||||
pref("services.sync.autoconnectDelay", 5);
|
||||
|
||||
// Drag thresholds
|
||||
pref("ui.dragThresholdX", 25);
|
||||
pref("ui.dragThresholdY", 25);
|
||||
|
|
|
@ -42,14 +42,15 @@
|
|||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
// how many msecs elapse before two taps are not a double tap
|
||||
// Maximum delay in ms between the two taps of a double-tap
|
||||
const kDoubleClickInterval = 400;
|
||||
|
||||
// threshold in ms to detect if the click is possibly a dblClick
|
||||
const kDoubleClickThreshold = 300;
|
||||
// If a tap lasts longer than this duration in ms, treat it as a single-tap
|
||||
// immediately instead of waiting for a possible double tap.
|
||||
const kDoubleClickThreshold = 200;
|
||||
|
||||
// threshold in pixels for sensing a tap as opposed to a pan
|
||||
const kTapRadius = 25;
|
||||
const kTapRadius = Services.prefs.getIntPref("ui.dragThresholdX");
|
||||
|
||||
// maximum drag distance in pixels while axis locking can still be reverted
|
||||
const kAxisLockRevertThreshold = 200;
|
||||
|
|
|
@ -130,34 +130,6 @@ let Util = {
|
|||
return Math.max(min, Math.min(max, num));
|
||||
},
|
||||
|
||||
/**
|
||||
* Determines whether a home page override is needed.
|
||||
* Returns:
|
||||
* "new profile" if this is the first run with a new profile.
|
||||
* "new version" if this is the first run with a build with a different
|
||||
* Gecko milestone (i.e. right after an upgrade).
|
||||
* "none" otherwise.
|
||||
*/
|
||||
needHomepageOverride: function needHomepageOverride() {
|
||||
let savedmstone = null;
|
||||
try {
|
||||
savedmstone = Services.prefs.getCharPref("browser.startup.homepage_override.mstone");
|
||||
} catch (e) {}
|
||||
|
||||
if (savedmstone == "ignore")
|
||||
return "none";
|
||||
|
||||
#expand let ourmstone = "__MOZ_APP_VERSION__";
|
||||
|
||||
if (ourmstone != savedmstone) {
|
||||
Services.prefs.setCharPref("browser.startup.homepage_override.mstone", ourmstone);
|
||||
|
||||
return (savedmstone ? "new version" : "new profile");
|
||||
}
|
||||
|
||||
return "none";
|
||||
},
|
||||
|
||||
/** Don't display anything in the urlbar for these special URIs. */
|
||||
isURLEmpty: function isURLEmpty(aURL) {
|
||||
return (!aURL || aURL == "about:blank" || aURL == "about:empty" || aURL == "about:home");
|
||||
|
|
|
@ -84,7 +84,7 @@
|
|||
</div>
|
||||
|
||||
<div id="about">
|
||||
<img src="chrome://browser/skin/images/mozilla-32.png"/> <a href="http://www.mozilla.com/about/">&aboutHome.aboutMozilla;</a>
|
||||
<img src="chrome://browser/skin/images/mozilla-32.png"/> <a href="http://www.mozilla.com/about/" onclick="openTabs([this.href]); return false;">&aboutHome.aboutMozilla;</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
@ -209,7 +209,8 @@
|
|||
}
|
||||
|
||||
if (allPageURLs.length > 0) {
|
||||
document.getElementById("loadingTabs").style.display = "none";
|
||||
let loading = document.getElementById("loadingTabs");
|
||||
loading.parentNode.removeChild(loading);
|
||||
|
||||
if (allPageURLs.length > 1) {
|
||||
let outer = document.createElement("div");
|
||||
|
@ -238,7 +239,8 @@
|
|||
updateWeaveButton();
|
||||
}
|
||||
else {
|
||||
document.getElementById("remoteTabs").style.display = "none";
|
||||
let loading = document.getElementById("remoteTabs");
|
||||
loading.parentNode.removeChild(loading);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -285,7 +287,8 @@
|
|||
return;
|
||||
}
|
||||
|
||||
document.getElementById("loadingAddons").style.display = "none";
|
||||
let loading = document.getElementById("loadingAddons");
|
||||
loading.parentNode.removeChild(loading);
|
||||
|
||||
for (let i=0; i<aAddons.length; i++) {
|
||||
let outer = document.createElement("div");
|
||||
|
@ -321,7 +324,8 @@
|
|||
},
|
||||
|
||||
searchFailed: function searchFailed() {
|
||||
document.getElementById("newAddons").style.display = "none";
|
||||
let loading = document.getElementById("newAddons");
|
||||
loading.parentNode.removeChild(loading);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
|
||||
<binding id="autocomplete-aligned" extends="chrome://global/content/bindings/autocomplete.xml#autocomplete">
|
||||
<implementation>
|
||||
<property name="mIgnoreFocus" onget="return true;"/>
|
||||
<method name="openPopup">
|
||||
<body><![CDATA[
|
||||
this.popup.openAutocompletePopup(this, null);
|
||||
|
@ -45,7 +46,7 @@
|
|||
</handler>
|
||||
<handler event="blur" phase="capturing">
|
||||
<![CDATA[
|
||||
// suppress disconnect of autocomplete controller
|
||||
// Bug 583341 - suppress disconnect of autocomplete controller
|
||||
this._dontBlur = true;
|
||||
]]>
|
||||
</handler>
|
||||
|
@ -53,12 +54,37 @@
|
|||
</binding>
|
||||
|
||||
<binding id="popup_autocomplete_result">
|
||||
<handlers>
|
||||
<handler event="contextmenu" phase="capturing">
|
||||
<![CDATA[
|
||||
let url = this.getAttribute("url");
|
||||
if (!url)
|
||||
return;
|
||||
|
||||
let value = this.getAttribute("value");
|
||||
let data = {
|
||||
target: this,
|
||||
json: {
|
||||
types: ["link-saveable", "link-shareable"],
|
||||
label: value,
|
||||
linkTitle: value,
|
||||
linkURL: url
|
||||
}
|
||||
};
|
||||
ContextHelper.showPopup(data);
|
||||
]]>
|
||||
</handler>
|
||||
</handlers>
|
||||
<content orient="vertical">
|
||||
<xul:hbox class="autocomplete-item-label" align="top" xbl:inherits="tags, favorite" mousethrough="always">
|
||||
<xul:hbox class="autocomplete-item-container" align="top" xbl:inherits="favorite" mousethrough="always">
|
||||
<xul:image xbl:inherits="src"/>
|
||||
<xul:vbox flex="1">
|
||||
<xul:label crop="center" xbl:inherits="value"/>
|
||||
<xul:label class="autocomplete-item-url" xbl:inherits="value=url" crop="center" mousethrough="always"/>
|
||||
<xul:label class="autocomplete-item-label" crop="center" xbl:inherits="value"/>
|
||||
<xul:label class="autocomplete-item-url" xbl:inherits="value=url" crop="center"/>
|
||||
</xul:vbox>
|
||||
<xul:vbox align="end">
|
||||
<xul:label class="autocomplete-item-tags" value="" xbl:inherits="value=tags"/>
|
||||
<xul:label class="autocomplete-item-badge" value="" xbl:inherits="value=badge"/>
|
||||
</xul:vbox>
|
||||
</xul:hbox>
|
||||
</content>
|
||||
|
@ -109,6 +135,11 @@
|
|||
this.boxObject.QueryInterface(Ci.nsIScrollBoxObject);
|
||||
</field>
|
||||
|
||||
<!-- Used by the badges implementation -->
|
||||
<field name="_badges">[]</field>
|
||||
<field name="_badgesTimeout">-1</field>
|
||||
<field name="_eTLDService">Cc["@mozilla.org/network/effective-tld-service;1"].getService(Ci.nsIEffectiveTLDService);</field>
|
||||
|
||||
<!-- nsIAutocompleteInput -->
|
||||
<property name="overrideValue"
|
||||
readonly="true"
|
||||
|
@ -237,7 +268,6 @@
|
|||
|
||||
continue;
|
||||
}
|
||||
item._empty = false;
|
||||
|
||||
// Assign the values
|
||||
let type = controller.getStyleAt(i);
|
||||
|
@ -253,11 +283,18 @@
|
|||
|
||||
let url = controller.getValueAt(i);
|
||||
item.setAttribute("value", title || url);
|
||||
item.setAttribute("url", url);
|
||||
|
||||
// remove the badge only if the url has changed
|
||||
if (item._empty || item.getAttribute("url") != url) {
|
||||
item.setAttribute("url", url);
|
||||
item.removeAttribute("badge");
|
||||
}
|
||||
|
||||
let isBookmark = ((type == "bookmark") || (type == "tag"));
|
||||
item.setAttribute("favorite", isBookmark);
|
||||
item.setAttribute("src", controller.getImageAt(i));
|
||||
|
||||
item._empty = false;
|
||||
}
|
||||
|
||||
// Show the "no results" or "all bookmarks" entries as needed
|
||||
|
@ -265,6 +302,7 @@
|
|||
|
||||
// Make sure the list is scrolled to the top
|
||||
this.scrollToTop();
|
||||
this._invalidateBadges();
|
||||
]]></body>
|
||||
</method>
|
||||
|
||||
|
@ -281,6 +319,7 @@
|
|||
noResultsItem.removeAttribute("url");
|
||||
noResultsItem.removeAttribute("src");
|
||||
noResultsItem.removeAttribute("tags");
|
||||
noResultsItem.removeAttribute("badge");
|
||||
}
|
||||
]]></body>
|
||||
</method>
|
||||
|
@ -307,6 +346,64 @@
|
|||
]]></body>
|
||||
</method>
|
||||
|
||||
<method name="_getEffectiveHost">
|
||||
<parameter name="aURI"/>
|
||||
<body><![CDATA[
|
||||
let host = null;
|
||||
try {
|
||||
host = aURI.host;
|
||||
return this._eTLDService.getBaseDomainFromHost(host);
|
||||
} catch (e) {}
|
||||
|
||||
return host ? host : aURI.spec;
|
||||
]]></body>
|
||||
</method>
|
||||
|
||||
<method name="registerBadgeHandler">
|
||||
<parameter name="aURL"/>
|
||||
<parameter name="aHandler"/>
|
||||
<body><![CDATA[
|
||||
if (!aHandler)
|
||||
return false;
|
||||
|
||||
let effectiveHost = this._getEffectiveHost(Services.io.newURI(aURL, null, null));
|
||||
this._badges[effectiveHost] = aHandler;
|
||||
return true;
|
||||
]]></body>
|
||||
</method>
|
||||
|
||||
<method name="unregisterBagdeHandler">
|
||||
<parameter name="aURL"/>
|
||||
<body><![CDATA[
|
||||
let effectiveHost = this._getEffectiveHost(Services.io.newURI(aURL, null, null));
|
||||
if (this._badges[effectiveHost])
|
||||
delete this._badges[effectiveHost];
|
||||
]]></body>
|
||||
</method>
|
||||
|
||||
<method name="_invalidateBadges">
|
||||
<body><![CDATA[
|
||||
window.clearTimeout(this._badgesTimeout);
|
||||
|
||||
this._badgesTimeout = window.setTimeout(function(self) {
|
||||
for (let i = 0; i < self._items.childNodes.length; i++) {
|
||||
let item = self._items.childNodes[i];
|
||||
if (!item.hasAttribute("url"))
|
||||
continue;
|
||||
|
||||
let itemHost = self._getEffectiveHost(Services.io.newURI(item.getAttribute("url"), null, null));
|
||||
for (let badgeHost in self._badges) {
|
||||
if (itemHost == badgeHost) {
|
||||
let handler = self._badges[badgeHost];
|
||||
handler.updateBadge ? handler.updateBadge(item) : handler(item);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}, 300, this);
|
||||
]]></body>
|
||||
</method>
|
||||
|
||||
<!-- Helpers -->
|
||||
<field name="_items">
|
||||
document.getAnonymousElementByAttribute(this,
|
||||
|
@ -364,13 +461,15 @@
|
|||
let data = {
|
||||
target: this,
|
||||
json: {
|
||||
types: ["edit-bookmark"],
|
||||
label: this.uri.spec
|
||||
}};
|
||||
ContextHelper.showPopup(data);
|
||||
]]>
|
||||
</handler>
|
||||
</handlers>
|
||||
types: ["edit-bookmark", "link-saveable", "link-shareable"],
|
||||
label: this.name,
|
||||
linkTitle: this.name,
|
||||
linkURL: this.spec
|
||||
}};
|
||||
ContextHelper.showPopup(data);
|
||||
]]>
|
||||
</handler>
|
||||
</handlers>
|
||||
|
||||
<implementation>
|
||||
<field name="_uri">null</field>
|
||||
|
@ -597,12 +696,15 @@
|
|||
|
||||
<binding id="place-item" extends="chrome://browser/content/bindings.xml#place-base">
|
||||
<content orient="vertical">
|
||||
<xul:hbox anonid="bookmark-item" class="bookmark-item-label" align="top" flex="1" xbl:inherits="tags" mousethrough="always">
|
||||
<xul:hbox anonid="bookmark-item" class="bookmark-item-container" align="top" flex="1" mousethrough="always">
|
||||
<xul:image xbl:inherits="src"/>
|
||||
<xul:vbox flex="1">
|
||||
<xul:label crop="center" xbl:inherits="value=title"/>
|
||||
<xul:label class="bookmark-item-label" crop="center" xbl:inherits="value=title"/>
|
||||
<xul:label anonid="bookmark-url" class="bookmark-item-url" xbl:inherits="value=uri" crop="center" mousethrough="always"/>
|
||||
</xul:vbox>
|
||||
<xul:vbox>
|
||||
<xul:label class="bookmark-item-tags" xbl:inherits="value=tags"/>
|
||||
</xul:vbox>
|
||||
</xul:hbox>
|
||||
|
||||
<xul:hbox anonid="bookmark-manage" class="bookmark-manage" hidden="true" flex="1">
|
||||
|
@ -1121,7 +1223,7 @@
|
|||
return;
|
||||
|
||||
tabs.push({
|
||||
title: title ? pageUrl : title,
|
||||
title: title || pageUrl,
|
||||
uri: pageUrl,
|
||||
icon: Weave.Utils.getIcon(icon, "chrome://browser/skin/images/tab.png")
|
||||
});
|
||||
|
|
|
@ -205,26 +205,31 @@ var BrowserUI = {
|
|||
|
||||
_editURI: function _editURI(aEdit) {
|
||||
if (aEdit) {
|
||||
// If the urlbar is not opened yet, inform the broadcaster and then
|
||||
// save the current value as a default value to display once the awesome
|
||||
// panel will be dismissed
|
||||
let isOpened = this._edit.hasAttribute("open");
|
||||
if (!isOpened) {
|
||||
Elements.urlbarState.setAttribute("mode", "edit");
|
||||
this._edit.defaultValue = this._edit.value;
|
||||
|
||||
// Now, replace the web page title by the url of the page
|
||||
let urlString = this.getDisplayURI(Browser.selectedBrowser);
|
||||
if (Util.isURLEmpty(urlString))
|
||||
urlString = "";
|
||||
this._edit.value = urlString;
|
||||
}
|
||||
|
||||
// Replace the web page title by the url of the page
|
||||
let urlString = this.getDisplayURI(Browser.selectedBrowser);
|
||||
if (Util.isURLEmpty(urlString))
|
||||
urlString = "";
|
||||
this._edit.value = urlString;
|
||||
|
||||
if (!this._edit.readOnly) {
|
||||
// If the urlbar readOnly state is set to false or if the window is in
|
||||
// portrait then we refresh the IME state to display the VKB if any
|
||||
if (!this._edit.readOnly || Util.isPortrait()) {
|
||||
// This is a workaround needed to cycle focus for the IME state
|
||||
// to be set properly (bug 488420)
|
||||
this._edit.blur();
|
||||
gFocusManager.setFocus(this._edit, Ci.nsIFocusManager.FLAG_NOSCROLL);
|
||||
}
|
||||
|
||||
this._edit.readOnly = !isOpened;
|
||||
this._edit.readOnly = false;
|
||||
}
|
||||
else if (!aEdit) {
|
||||
this._updateToolbar();
|
||||
|
@ -392,6 +397,8 @@ var BrowserUI = {
|
|||
this._edit.addEventListener("click", this, false);
|
||||
this._edit.addEventListener("mousedown", this, false);
|
||||
|
||||
BadgeHandlers.register(this._edit.popup);
|
||||
|
||||
let awesomePopup = document.getElementById("popup_autocomplete");
|
||||
awesomePopup.addEventListener("popupshown", this, false);
|
||||
awesomePopup.addEventListener("popuphidden", this, false);
|
||||
|
@ -566,6 +573,11 @@ var BrowserUI = {
|
|||
this._edit.popup.close();
|
||||
else
|
||||
this._edit.popup.closePopup();
|
||||
|
||||
// Because the controller is not detached during a blur event for Meego
|
||||
// compatibility with the VKB, we need to detach it manually
|
||||
this._edit.detachController();
|
||||
this.activePanel = null;
|
||||
},
|
||||
|
||||
isAutoCompleteOpen: function isAutoCompleteOpen() {
|
||||
|
@ -578,7 +590,6 @@ var BrowserUI = {
|
|||
|
||||
// Give the new page lots of room
|
||||
Browser.hideSidebars();
|
||||
this.activePanel = null;
|
||||
this.closeAutoComplete(false);
|
||||
|
||||
// Make sure we're online before attempting to load
|
||||
|
@ -632,6 +643,7 @@ var BrowserUI = {
|
|||
},
|
||||
|
||||
selectTab: function selectTab(aTab) {
|
||||
this.activePanel = null;
|
||||
Browser.selectedTab = aTab;
|
||||
},
|
||||
|
||||
|
@ -927,7 +939,6 @@ var BrowserUI = {
|
|||
break;
|
||||
case "cmd_go":
|
||||
this.goToURI();
|
||||
this.activePanel = null;
|
||||
break;
|
||||
case "cmd_openLocation":
|
||||
this.showToolbar(true);
|
||||
|
@ -1380,8 +1391,8 @@ var AwesomePanel = function(aElementId, aCommandId) {
|
|||
let item = aEvent.originalTarget;
|
||||
let uri = item.getAttribute("url") || item.getAttribute("uri");
|
||||
if (uri != "") {
|
||||
BrowserUI.activePanel = null;
|
||||
BrowserUI.goToURI(uri);
|
||||
BrowserUI.activePanel = null;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -2413,7 +2424,6 @@ var ContextCommands = {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
var SharingUI = {
|
||||
_dialog: null,
|
||||
|
||||
|
@ -2480,3 +2490,74 @@ var SharingUI = {
|
|||
]
|
||||
};
|
||||
|
||||
|
||||
var BadgeHandlers = {
|
||||
_handlers: [
|
||||
{
|
||||
_lastUpdate: 0,
|
||||
_lastCount: 0,
|
||||
url: "http://mail.google.com",
|
||||
updateBadge: function(aItem) {
|
||||
// Use the cache if possible
|
||||
let now = Date.now();
|
||||
if (this._lastCount && this._lastUpdate > now - 1000) {
|
||||
aItem.setAttribute("badge", this._lastCount);
|
||||
return;
|
||||
}
|
||||
|
||||
this._lastUpdate = now;
|
||||
|
||||
// Use any saved username and password. If we don't have any login and we are not
|
||||
// currently logged into Gmail, we won't get any count.
|
||||
let login = BadgeHandlers.getLogin("https://www.google.com");
|
||||
|
||||
// Get the feed and read the count, passing any saved username and password
|
||||
// but do not show any security dialogs if we fail
|
||||
let req = new XMLHttpRequest();
|
||||
req.mozBackgroundRequest = true;
|
||||
req.open("GET", "https://mail.google.com/mail/feed/atom", true, login.username, login.password);
|
||||
req.onreadystatechange = function(aEvent) {
|
||||
if (req.readyState == 4) {
|
||||
if (req.status == 200) {
|
||||
this._lastCount = req.responseXML.getElementsByTagName("fullcount")[0].childNodes[0].nodeValue;
|
||||
} else {
|
||||
this._lastCount = 0;
|
||||
}
|
||||
this._lastCount = BadgeHandlers.setNumberBadge(aItem, this._lastCount);
|
||||
}
|
||||
};
|
||||
req.send(null);
|
||||
}
|
||||
}
|
||||
],
|
||||
|
||||
register: function(aPopup) {
|
||||
let handlers = this._handlers;
|
||||
for (let i = 0; i < handlers.length; i++)
|
||||
aPopup.registerBadgeHandler(handlers[i].url, handlers[i]);
|
||||
},
|
||||
|
||||
getLogin: function(aURL) {
|
||||
let lm = Cc["@mozilla.org/login-manager;1"].getService(Ci.nsILoginManager);
|
||||
let logins = lm.findLogins({}, aURL, aURL, null);
|
||||
let username = logins.length > 0 ? logins[0].username : "";
|
||||
let password = logins.length > 0 ? logins[0].password : "";
|
||||
return { username: username, password: password };
|
||||
},
|
||||
|
||||
clampBadge: function(aValue) {
|
||||
if (aValue > 100)
|
||||
aValue = "99+";
|
||||
return aValue;
|
||||
},
|
||||
|
||||
setNumberBadge: function(aItem, aValue) {
|
||||
if (parseInt(aValue) != 0) {
|
||||
aValue = this.clampBadge(aValue);
|
||||
aItem.setAttribute("badge", aValue);
|
||||
} else {
|
||||
aItem.removeAttribute("badge");
|
||||
}
|
||||
return aValue;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -56,7 +56,7 @@ function getBrowser() {
|
|||
return Browser.selectedBrowser;
|
||||
}
|
||||
|
||||
const kDefaultBrowserWidth = 800;
|
||||
const kDefaultBrowserWidth = 980;
|
||||
const kBrowserFormZoomLevelMin = 1.0;
|
||||
const kBrowserFormZoomLevelMax = 2.0;
|
||||
const kBrowserViewZoomLevelPrecision = 10000;
|
||||
|
@ -168,10 +168,6 @@ var Browser = {
|
|||
dump("###########" + e + "\n");
|
||||
}
|
||||
|
||||
let needOverride = Util.needHomepageOverride();
|
||||
if (needOverride == "new profile")
|
||||
this.initNewProfile();
|
||||
|
||||
let container = document.getElementById("browsers");
|
||||
// XXX change
|
||||
|
||||
|
@ -302,45 +298,13 @@ var Browser = {
|
|||
// Make sure we're online before attempting to load
|
||||
Util.forceOnline();
|
||||
|
||||
// Command line arguments/initial homepage
|
||||
let whereURI = this.getHomePage();
|
||||
if (needOverride == "new profile")
|
||||
whereURI = "about:firstrun";
|
||||
// If this is an intial window launch the commandline handler passes us the default
|
||||
// page as an argument
|
||||
let defaultURL = this.getHomePage();
|
||||
if (window.arguments && window.arguments[0])
|
||||
defaultURL = window.arguments[0];
|
||||
|
||||
// If this is an intial window launch (was a nsICommandLine passed via window params)
|
||||
// we execute some logic to load the initial launch page
|
||||
if (window.arguments && window.arguments[0]) {
|
||||
if (window.arguments[0] instanceof Ci.nsICommandLine) {
|
||||
try {
|
||||
var cmdLine = window.arguments[0];
|
||||
|
||||
// Check for and use a single commandline parameter
|
||||
if (cmdLine.length == 1) {
|
||||
// Assume the first arg is a URI if it is not a flag
|
||||
var uri = cmdLine.getArgument(0);
|
||||
if (uri != "" && uri[0] != '-') {
|
||||
whereURI = cmdLine.resolveURI(uri);
|
||||
if (whereURI)
|
||||
whereURI = whereURI.spec;
|
||||
}
|
||||
}
|
||||
|
||||
// Check for the "url" flag
|
||||
var uriFlag = cmdLine.handleFlagWithParam("url", false);
|
||||
if (uriFlag) {
|
||||
whereURI = cmdLine.resolveURI(uriFlag);
|
||||
if (whereURI)
|
||||
whereURI = whereURI.spec;
|
||||
}
|
||||
} catch (e) {}
|
||||
}
|
||||
else {
|
||||
// This window could have been opened by nsIBrowserDOMWindow.openURI
|
||||
whereURI = window.arguments[0];
|
||||
}
|
||||
}
|
||||
|
||||
this.addTab(whereURI, true);
|
||||
this.addTab(defaultURL, true);
|
||||
|
||||
// JavaScript Error Console
|
||||
if (Services.prefs.getBoolPref("browser.console.showInPanel")){
|
||||
|
@ -448,9 +412,6 @@ var Browser = {
|
|||
window.controllers.removeController(BrowserUI);
|
||||
},
|
||||
|
||||
initNewProfile: function initNewProfile() {
|
||||
},
|
||||
|
||||
getHomePage: function () {
|
||||
let url = "about:home";
|
||||
try {
|
||||
|
|
|
@ -349,10 +349,6 @@
|
|||
</hbox>
|
||||
</vbox>
|
||||
|
||||
<vbox id="newtab-popup" hidden="true" class="dialog-dark" onclick="NewTabPopup.selectTab()" align="center" left="21">
|
||||
<label/>
|
||||
</vbox>
|
||||
|
||||
<vbox id="bookmark-popup" hidden="true" class="dialog-dark" align="center">
|
||||
<label value="&bookmarkPopup.label;"/>
|
||||
<separator class="thin"/>
|
||||
|
@ -515,6 +511,10 @@
|
|||
<remotetabslist id="remotetabs-items" onopen="RemoteTabsList.openLink(event)" flex="1" hidden="true"/>
|
||||
</vbox>
|
||||
|
||||
<vbox id="newtab-popup" hidden="true" class="dialog-dark" onclick="NewTabPopup.selectTab()" align="center" left="21">
|
||||
<label/>
|
||||
</vbox>
|
||||
|
||||
<!-- options dialog for select form field -->
|
||||
<vbox id="select-container" hidden="true" pack="center">
|
||||
<spacer id="select-spacer" flex="1000"/>
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Mozilla Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2008
|
||||
* Portions created by the Initial Developer are Copyright (C) 2010
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
|
@ -85,8 +85,6 @@ var ViewConfig = {
|
|||
open: function open(aType) {
|
||||
let buttons = document.getElementById("editor-buttons-add");
|
||||
buttons.setAttribute("hidden", "true");
|
||||
let nameField = document.getElementById("editor-name");
|
||||
nameField.value = "";
|
||||
|
||||
let shouldFocus = false;
|
||||
let setting = document.getElementById("editor-setting");
|
||||
|
@ -108,6 +106,9 @@ var ViewConfig = {
|
|||
setting.input.value = "";
|
||||
|
||||
document.getElementById("editor-container").appendChild(this._editor);
|
||||
let nameField = document.getElementById("editor-name");
|
||||
nameField.value = "";
|
||||
|
||||
this._editor.setAttribute("hidden", "false");
|
||||
this._currentItem = null;
|
||||
nameField.focus();
|
||||
|
@ -119,13 +120,14 @@ var ViewConfig = {
|
|||
buttons.setAttribute("hidden", "false");
|
||||
|
||||
if (aValid) {
|
||||
let name = document.getElementById("editor-name").value;
|
||||
let name = document.getElementById("editor-name").inputField.value;
|
||||
if (name != "") {
|
||||
let setting = document.getElementById("editor-setting");
|
||||
setting.setAttribute("pref", name);
|
||||
setting.valueToPreference();
|
||||
}
|
||||
}
|
||||
|
||||
document.getElementById("editor-container").appendChild(this._editor);
|
||||
},
|
||||
|
||||
|
@ -397,7 +399,7 @@ var Utils = {
|
|||
},
|
||||
|
||||
_generateRegexp: function _generateRegexp(aValue) {
|
||||
if (aValue.charAt(0) == '/') {
|
||||
if (aValue.charAt(0) == "/") {
|
||||
try {
|
||||
let rv = aValue.match(/^\/(.*)\/(i?)$/);
|
||||
return RegExp(rv[1], rv[2]);
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
-
|
||||
- The Initial Developer of the Original Code is
|
||||
- Mozilla Corporation.
|
||||
- Portions created by the Initial Developer are Copyright (C) 2008
|
||||
- Portions created by the Initial Developer are Copyright (C) 2010
|
||||
- the Initial Developer. All Rights Reserved.
|
||||
-
|
||||
- Contributor(s):
|
||||
|
@ -69,9 +69,9 @@
|
|||
<label value="&newpref.label;" flex="1"/>
|
||||
<spacer flex="1" />
|
||||
<hbox id="editor-buttons-add">
|
||||
<button label="&integer.label;" oncommand="ViewConfig.open(Components.interfaces.nsIPrefBranch.PREF_INT)"/>
|
||||
<button label="&boolean.label;" oncommand="ViewConfig.open(Components.interfaces.nsIPrefBranch.PREF_BOOL)"/>
|
||||
<button label="&string.label;" oncommand="ViewConfig.open(Components.interfaces.nsIPrefBranch.PREF_STRING)"/>
|
||||
<button label="&integer.label;" oncommand="ViewConfig.open(Ci.nsIPrefBranch.PREF_INT)"/>
|
||||
<button label="&boolean.label;" oncommand="ViewConfig.open(Ci.nsIPrefBranch.PREF_BOOL)"/>
|
||||
<button label="&string.label;" oncommand="ViewConfig.open(Ci.nsIPrefBranch.PREF_STRING)"/>
|
||||
</hbox>
|
||||
</hbox>
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
dump("###################################### content loaded\n");
|
||||
|
||||
// how many milliseconds before the mousedown and the overlay of an element
|
||||
const kTapOverlayTimeout = 300;
|
||||
const kTapOverlayTimeout = 200;
|
||||
|
||||
let Cc = Components.classes;
|
||||
let Ci = Components.interfaces;
|
||||
|
|
|
@ -808,8 +808,10 @@ AddonInstallListener.prototype = {
|
|||
error += aInstall.error;
|
||||
else if (aInstall.addon.blocklistState == Ci.nsIBlocklistService.STATE_BLOCKED)
|
||||
error += "Blocklisted";
|
||||
else
|
||||
else if (!aInstall.addon.isCompatible)
|
||||
error += "Incompatible";
|
||||
else
|
||||
return; // no need to show anything in this case
|
||||
|
||||
let messageString = strings.getString(error);
|
||||
messageString = messageString.replace("#1", aInstall.name);
|
||||
|
|
|
@ -79,6 +79,8 @@ _BROWSER_FILES = \
|
|||
browser_viewport_08.html \
|
||||
browser_viewport_09.html \
|
||||
browser_viewport.js \
|
||||
browser_no_title.html \
|
||||
browser_english_title.html \
|
||||
$(NULL)
|
||||
|
||||
libs:: $(_BROWSER_FILES)
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
<html>
|
||||
<head><title>English Title Page</title>
|
||||
<link rel="shortcut icon"
|
||||
href="data:image/gif;base64,R0lGODlhCwALAIAAAAAA3pn/ZiH5BAEAAAEALAAAAAALAAsAAAIUhA+hkcuO4lmNVindo7qyrIXiGBYAOw==" />
|
||||
</head>
|
||||
<body>This is english title page</body>
|
||||
</html>
|
|
@ -1,5 +1,8 @@
|
|||
var testURL_01 = "chrome://mochikit/content/browser/mobile/chrome/browser_blank_01.html";
|
||||
var testURL_02 = "chrome://mochikit/content/browser/mobile/chrome/browser_blank_02.html";
|
||||
var testURL_03 = "chrome://mochikit/content/browser/mobile/chrome/browser_english_title.html";
|
||||
var testURL_04 = "chrome://mochikit/content/browser/mobile/chrome/browser_no_title.html";
|
||||
var pngURL = "data:image/gif;base64,R0lGODlhCwALAIAAAAAA3pn/ZiH5BAEAAAEALAAAAAALAAsAAAIUhA+hkcuO4lmNVindo7qyrIXiGBYAOw==";
|
||||
|
||||
// A queue to order the tests and a handle for each test
|
||||
var gTests = [];
|
||||
|
@ -18,7 +21,6 @@ function test() {
|
|||
// The "runNextTest" approach is async, so we need to call "waitForExplicitFinish()"
|
||||
// We call "finish()" when the tests are finished
|
||||
waitForExplicitFinish();
|
||||
|
||||
// Start the tests
|
||||
runNextTest();
|
||||
}
|
||||
|
@ -51,7 +53,7 @@ gTests.push({
|
|||
_currentTab: null,
|
||||
|
||||
run: function() {
|
||||
this._currentTab = Browser.addTab(testURL_01, true);
|
||||
gCurrentTest._currentTab = Browser.addTab(testURL_01, true);
|
||||
|
||||
// Wait for the tab to load, then do the test
|
||||
waitFor(gCurrentTest.onPageReady, pageLoaded(testURL_01));
|
||||
|
@ -80,6 +82,7 @@ gTests.push({
|
|||
|
||||
onFocusReady: function() {
|
||||
window.removeEventListener("popupshown", gCurrentTest.onFocusReady, false);
|
||||
|
||||
// Test mode
|
||||
let urlIcons = document.getElementById("urlbar-icons");
|
||||
is(urlIcons.getAttribute("mode"), "edit", "URL Mode is set to 'edit'");
|
||||
|
@ -93,9 +96,9 @@ gTests.push({
|
|||
is(forward.disabled, !gCurrentTest._currentTab.browser.canGoForward, "Forward button check");
|
||||
|
||||
// Check button states (url edit is focused)
|
||||
let go = document.getElementById("tool-go");
|
||||
let goStyle = window.getComputedStyle(go, null);
|
||||
is(goStyle.visibility, "visible", "GO is visible");
|
||||
let search = document.getElementById("tool-search");
|
||||
let searchStyle = window.getComputedStyle(search, null);
|
||||
is(searchStyle.visibility, "visible", "SEARCH is visible");
|
||||
|
||||
let stop = document.getElementById("tool-stop");
|
||||
let stopStyle = window.getComputedStyle(stop, null);
|
||||
|
@ -118,9 +121,9 @@ gTests.push({
|
|||
is(urlIcons.getAttribute("mode"), "view", "URL Mode is set to 'view'");
|
||||
|
||||
// Check button states (url edit is not focused)
|
||||
let go = document.getElementById("tool-go");
|
||||
let goStyle = window.getComputedStyle(go, null);
|
||||
is(goStyle.visibility, "collapse", "GO is hidden");
|
||||
let search = document.getElementById("tool-search");
|
||||
let searchStyle = window.getComputedStyle(search, null);
|
||||
is(searchStyle.visibility, "collapse", "SEARCH is hidden");
|
||||
|
||||
let stop = document.getElementById("tool-stop");
|
||||
let stopStyle = window.getComputedStyle(stop, null);
|
||||
|
@ -150,30 +153,58 @@ gTests.push({
|
|||
is(forward.disabled, !gCurrentTest._currentTab.browser.canGoForward, "Forward button check");
|
||||
|
||||
Browser.closeTab(gCurrentTest._currentTab);
|
||||
|
||||
runNextTest();
|
||||
}
|
||||
});
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Case: Loading a page into the URLBar with GO button
|
||||
// Bug 570706 - --browser-chrome Mochitests on Fennec [post navigation]
|
||||
// Check for text in the url bar for no title, with title and title change after pageload
|
||||
gTests.push({
|
||||
desc: "Loading a page into the URLBar with GO button",
|
||||
desc: "Check for text in the url bar for no title, with title and title change after pageload",
|
||||
_currentTab: null,
|
||||
|
||||
run: function() {
|
||||
this._currentTab = Browser.addTab(testURL_01, true);
|
||||
gCurrentTest._currentTab = Browser.addTab(testURL_03, true);
|
||||
|
||||
// Wait for the tab to load, then do the test
|
||||
waitFor(gCurrentTest.onPageReady, pageLoaded(testURL_01));
|
||||
messageManager.addMessageListener("pageshow", function() {
|
||||
if (gCurrentTest._currentTab.browser.currentURI.spec == testURL_03) {
|
||||
messageManager.removeMessageListener("pageshow", arguments.callee);
|
||||
gCurrentTest.onPageReady();
|
||||
}});
|
||||
},
|
||||
|
||||
onPageReady: function() {
|
||||
let urlIcons = document.getElementById("urlbar-icons");
|
||||
is(urlIcons.getAttribute("mode"), "view", "URL Mode is set to 'view'");
|
||||
|
||||
// Focus the url edit
|
||||
let urlbarEdit = document.getElementById("urlbar-edit");
|
||||
is(urlbarEdit.value, "English Title Page", "The title must be displayed in urlbar");
|
||||
Browser.closeTab(gCurrentTest._currentTab);
|
||||
gCurrentTest._currentTab = Browser.addTab(testURL_04, true);
|
||||
|
||||
messageManager.addMessageListener("pageshow", function() {
|
||||
if (gCurrentTest._currentTab.browser.currentURI.spec == testURL_04) {
|
||||
messageManager.removeMessageListener("pageshow", arguments.callee);
|
||||
gCurrentTest.onPageReady2();
|
||||
}});
|
||||
},
|
||||
|
||||
onPageReady2: function(){
|
||||
let urlbarEdit = document.getElementById("urlbar-edit");
|
||||
is(urlbarEdit.value, testURL_04, "The url for no title must be displayed in urlbar");
|
||||
Browser.closeTab(gCurrentTest._currentTab);
|
||||
|
||||
// Check whether title appears after a pageload
|
||||
gCurrentTest._currentTab = Browser.addTab(testURL_01, true);
|
||||
messageManager.addMessageListener("pageshow", function() {
|
||||
if (gCurrentTest._currentTab.browser.currentURI.spec == testURL_01) {
|
||||
messageManager.removeMessageListener("pageshow", arguments.callee);
|
||||
gCurrentTest.onPageReady3();
|
||||
}});
|
||||
},
|
||||
|
||||
onPageReady3: function(){
|
||||
let urlbarEdit = document.getElementById("urlbar-edit");
|
||||
is(urlbarEdit.value, "Browser Blank Page 01", "The title of the first page must be displayed");
|
||||
EventUtils.synthesizeMouse(urlbarEdit, urlbarEdit.clientWidth / 2, urlbarEdit.clientHeight / 2, {});
|
||||
|
||||
// Wait for the awesomebar to load, then do the test
|
||||
|
@ -182,51 +213,57 @@ gTests.push({
|
|||
|
||||
onFocusReady: function() {
|
||||
window.removeEventListener("popupshown", gCurrentTest.onFocusReady, false);
|
||||
let urlIcons = document.getElementById("urlbar-icons");
|
||||
is(urlIcons.getAttribute("mode"), "edit", "URL Mode is set to 'edit'");
|
||||
|
||||
// Check button states (url edit is focused)
|
||||
let go = document.getElementById("tool-go");
|
||||
let goStyle = window.getComputedStyle(go, null);
|
||||
is(goStyle.visibility, "visible", "GO is visible");
|
||||
|
||||
let stop = document.getElementById("tool-stop");
|
||||
let stopStyle = window.getComputedStyle(stop, null);
|
||||
is(stopStyle.visibility, "collapse", "STOP is hidden");
|
||||
|
||||
let reload = document.getElementById("tool-reload");
|
||||
let reloadStyle = window.getComputedStyle(reload, null);
|
||||
is(reloadStyle.visibility, "collapse", "RELOAD is hidden");
|
||||
|
||||
EventUtils.synthesizeString(testURL_02, window);
|
||||
EventUtils.synthesizeMouse(go, go.clientWidth / 2, go.clientHeight / 2, {});
|
||||
EventUtils.synthesizeKey("VK_RETURN", {}, window)
|
||||
|
||||
// Wait for the tab to load, then do the test
|
||||
waitFor(gCurrentTest.onPageFinish, pageLoaded(testURL_02));
|
||||
messageManager.addMessageListener("pageshow", function() {
|
||||
if (gCurrentTest._currentTab.browser.currentURI.spec == testURL_02) {
|
||||
messageManager.removeMessageListener("pageshow", arguments.callee);
|
||||
gCurrentTest.onPageFinish();
|
||||
}});
|
||||
},
|
||||
|
||||
onPageFinish: function() {
|
||||
let urlIcons = document.getElementById("urlbar-icons");
|
||||
is(urlIcons.getAttribute("mode"), "view", "URL Mode is set to 'view'");
|
||||
|
||||
// Check button states (url edit is not focused)
|
||||
let go = document.getElementById("tool-go");
|
||||
let goStyle = window.getComputedStyle(go, null);
|
||||
is(goStyle.visibility, "collapse", "GO is hidden");
|
||||
|
||||
let stop = document.getElementById("tool-stop");
|
||||
let stopStyle = window.getComputedStyle(stop, null);
|
||||
is(stopStyle.visibility, "collapse", "STOP is hidden");
|
||||
|
||||
let reload = document.getElementById("tool-reload");
|
||||
let reloadStyle = window.getComputedStyle(reload, null);
|
||||
is(reloadStyle.visibility, "visible", "RELOAD is visible");
|
||||
|
||||
let uri = gCurrentTest._currentTab.browser.currentURI.spec;
|
||||
is(uri, testURL_02, "URL Matches newly created Tab");
|
||||
|
||||
let urlbarEdit = document.getElementById("urlbar-edit");
|
||||
is(urlbarEdit.value, "Browser Blank Page 02", "The title of the second page must be displayed");
|
||||
Browser.closeTab(gCurrentTest._currentTab);
|
||||
|
||||
runNextTest();
|
||||
}
|
||||
});
|
||||
|
||||
// Case: Check for appearance of the favicon
|
||||
gTests.push({
|
||||
desc: "Check for appearance of the favicon",
|
||||
_currentTab: null,
|
||||
|
||||
run: function() {
|
||||
gCurrentTest._currentTab = Browser.addTab(testURL_04, true);
|
||||
messageManager.addMessageListener("pageshow", function() {
|
||||
|
||||
if (gCurrentTest._currentTab.browser.currentURI.spec == testURL_04) {
|
||||
messageManager.removeMessageListener("pageshow", arguments.callee);
|
||||
gCurrentTest.onPageReady();
|
||||
}});
|
||||
},
|
||||
|
||||
onPageReady: function() {
|
||||
let favicon = document.getElementById("urlbar-favicon");
|
||||
is(favicon.src, "", "The default favicon must be loaded");
|
||||
Browser.closeTab(gCurrentTest._currentTab);
|
||||
|
||||
gCurrentTest._currentTab = Browser.addTab(testURL_03, true);
|
||||
messageManager.addMessageListener("pageshow", function() {
|
||||
if (gCurrentTest._currentTab.browser.currentURI.spec == testURL_03) {
|
||||
messageManager.removeMessageListener("pageshow", arguments.callee);
|
||||
gCurrentTest.onPageFinish();
|
||||
}});
|
||||
},
|
||||
|
||||
onPageFinish: function(){
|
||||
let favicon = document.getElementById("urlbar-favicon");
|
||||
is(favicon.src, pngURL, "The page favicon must be loaded");
|
||||
Browser.closeTab(gCurrentTest._currentTab);
|
||||
runNextTest();
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
<html>
|
||||
<head>
|
||||
</head>
|
||||
<body>
|
||||
Hi this is a no title page
|
||||
</body>
|
||||
</html>
|
|
@ -55,7 +55,7 @@ function pageLoaded(url) {
|
|||
}
|
||||
|
||||
let testData = [
|
||||
{ width: 800, scale: 1 },
|
||||
{ width: 980, scale: 800/980 },
|
||||
{ width: 533.33, scale: 1.5 },
|
||||
{ width: 533.33, scale: 1.5 },
|
||||
{ width: 533.33, scale: 1.5, disableZoom: true },
|
||||
|
@ -92,7 +92,7 @@ function verifyBlank(n) {
|
|||
|
||||
// Check viewport settings
|
||||
let style = window.getComputedStyle(working_tab.browser, null);
|
||||
is(style.width, "800px", "Normal 'browser' width is 800 pixels");
|
||||
is(style.width, "980px", "Normal 'browser' width is 980 pixels");
|
||||
|
||||
loadTest(n);
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
<meta name="viewport" content=""/>
|
||||
|
||||
<!-- Expected: treat page like a desktop webpage -->
|
||||
<meta name="expected-width" content="800"/>
|
||||
<meta name="expected-width" content="980"/>
|
||||
<meta name="expected-scale" content="1"/>
|
||||
</head>
|
||||
<body>
|
||||
|
|
|
@ -42,8 +42,14 @@ const Cu = Components.utils;
|
|||
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
function openWindow(aParent, aURL, aTarget, aFeatures) {
|
||||
return Services.ww.openWindow(aParent, aURL, aTarget, aFeatures, null);
|
||||
function openWindow(aParent, aURL, aTarget, aFeatures, aArgs) {
|
||||
let argString = null;
|
||||
if (aArgs) {
|
||||
argString = Cc["@mozilla.org/supports-string;1"].createInstance(Ci.nsISupportsString);
|
||||
argString.data = aArgs;
|
||||
}
|
||||
|
||||
return Services.ww.openWindow(aParent, aURL, aTarget, aFeatures, argString);
|
||||
}
|
||||
|
||||
function resolveURIInternal(aCmdLine, aArgument) {
|
||||
|
@ -71,6 +77,43 @@ function resolveURIInternal(aCmdLine, aArgument) {
|
|||
return uri;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether a home page override is needed.
|
||||
* Returns:
|
||||
* "new profile" if this is the first run with a new profile.
|
||||
* "new version" if this is the first run with a build with a different
|
||||
* Gecko milestone (i.e. right after an upgrade).
|
||||
* "none" otherwise.
|
||||
*/
|
||||
function needHomepageOverride() {
|
||||
let savedmstone = null;
|
||||
try {
|
||||
savedmstone = Services.prefs.getCharPref("browser.startup.homepage_override.mstone");
|
||||
} catch (e) {}
|
||||
|
||||
if (savedmstone == "ignore")
|
||||
return "none";
|
||||
|
||||
#expand let ourmstone = "__MOZ_APP_VERSION__";
|
||||
|
||||
if (ourmstone != savedmstone) {
|
||||
Services.prefs.setCharPref("browser.startup.homepage_override.mstone", ourmstone);
|
||||
|
||||
return (savedmstone ? "new version" : "new profile");
|
||||
}
|
||||
|
||||
return "none";
|
||||
}
|
||||
|
||||
function getHomePage() {
|
||||
let url = "about:home";
|
||||
try {
|
||||
url = Services.prefs.getComplexValue("browser.startup.homepage", Ci.nsIPrefLocalizedString).data;
|
||||
} catch (e) { }
|
||||
|
||||
return url;
|
||||
}
|
||||
|
||||
|
||||
function BrowserCLH() { }
|
||||
|
||||
|
@ -95,12 +138,14 @@ BrowserCLH.prototype = {
|
|||
let chromeParam = aCmdLine.handleFlagWithParam("chrome", false);
|
||||
if (chromeParam) {
|
||||
try {
|
||||
// only load URIs which do not inherit chrome privs
|
||||
// Only load URIs which do not inherit chrome privs
|
||||
let features = "chrome,dialog=no,all";
|
||||
let uri = resolveURIInternal(aCmdLine, chromeParam);
|
||||
let netutil = Cc["@mozilla.org/network/util;1"].getService(Ci.nsINetUtil);
|
||||
if (!netutil.URIChainHasFlags(uri, Ci.nsIHttpProtocolHandler.URI_INHERITS_SECURITY_CONTEXT)) {
|
||||
openWindow(null, uri.spec, "_blank", features);
|
||||
openWindow(null, uri.spec, "_blank", features, null);
|
||||
|
||||
// Stop the normal commandline processing from continuing
|
||||
aCmdLine.preventDefault = true;
|
||||
}
|
||||
}
|
||||
|
@ -109,18 +154,17 @@ BrowserCLH.prototype = {
|
|||
}
|
||||
}
|
||||
|
||||
let win;
|
||||
try {
|
||||
win = Services.wm.getMostRecentWindow("navigator:browser");
|
||||
if (!win)
|
||||
return;
|
||||
// Keep an array of possible URL arguments
|
||||
let uris = [];
|
||||
|
||||
win.focus();
|
||||
aCmdLine.preventDefault = true;
|
||||
} catch (e) { }
|
||||
// Check for the "url" flag
|
||||
let uriFlag = aCmdLine.handleFlagWithParam("url", false);
|
||||
if (uriFlag) {
|
||||
let uri = resolveURIInternal(aCmdLine, uriFlag);
|
||||
if (uri)
|
||||
uris.push(uri);
|
||||
}
|
||||
|
||||
// Assumption: All CLH arguments we've received have been sent remotely,
|
||||
// or we wouldn't already have a window. Therefore: open 'em all!
|
||||
for (let i = 0; i < aCmdLine.length; i++) {
|
||||
let arg = aCmdLine.getArgument(i);
|
||||
if (!arg || arg[0] == '-')
|
||||
|
@ -128,8 +172,46 @@ BrowserCLH.prototype = {
|
|||
|
||||
let uri = resolveURIInternal(aCmdLine, arg);
|
||||
if (uri)
|
||||
win.browserDOMWindow.openURI(uri, null, Ci.nsIBrowserDOMWindow.OPEN_NEWTAB, null);
|
||||
uris.push(uri);
|
||||
}
|
||||
|
||||
// Open the main browser window, if we don't already have one
|
||||
let win;
|
||||
try {
|
||||
win = Services.wm.getMostRecentWindow("navigator:browser");
|
||||
if (!win) {
|
||||
// Default to the saved homepage
|
||||
let defaultURL = getHomePage();
|
||||
|
||||
// Override the default if we have a new profile
|
||||
if (needHomepageOverride() == "new profile")
|
||||
defaultURL = "about:firstrun";
|
||||
|
||||
// Override the default if we have a URL passed on command line
|
||||
if (uris.length > 0) {
|
||||
defaultURL = uris[0].spec;
|
||||
uris = uris.slice(1);
|
||||
}
|
||||
|
||||
win = openWindow(null, "chrome://browser/content/browser.xul", "_blank", "chrome,dialog=no,all", defaultURL);
|
||||
}
|
||||
|
||||
win.focus();
|
||||
|
||||
// Stop the normal commandline processing from continuing. We just opened the main browser window
|
||||
aCmdLine.preventDefault = true;
|
||||
} catch (e) { }
|
||||
|
||||
// Assumption: All remaining command line arguments have been sent remotely (browser is already running)
|
||||
// Action: Open any URLs we find into an existing browser window
|
||||
|
||||
// First, get a browserDOMWindow object
|
||||
while (!win.browserDOMWindow)
|
||||
Services.tm.currentThread.processNextEvent(true);
|
||||
|
||||
// Open any URIs into new tabs
|
||||
for (let i = 0; i < uris.length; i++)
|
||||
win.browserDOMWindow.openURI(uris[i], null, Ci.nsIBrowserDOMWindow.OPEN_NEWTAB, null);
|
||||
},
|
||||
|
||||
// QI
|
||||
|
|
|
@ -7,16 +7,19 @@ Cu.import("resource://gre/modules/Services.jsm");
|
|||
|
||||
const kCountBeforeWeRemember = 5;
|
||||
|
||||
function GeolocationPrompt() {}
|
||||
function ContentPermissionPrompt() {}
|
||||
|
||||
GeolocationPrompt.prototype = {
|
||||
ContentPermissionPrompt.prototype = {
|
||||
classID: Components.ID("{C6E8C44D-9F39-4AF7-BCC0-76E38A8310F5}"),
|
||||
|
||||
QueryInterface: XPCOMUtils.generateQI([Ci.nsIGeolocationPrompt]),
|
||||
QueryInterface: XPCOMUtils.generateQI([Ci.nsIContentPermissionPrompt]),
|
||||
|
||||
prompt: function(aRequest) {
|
||||
if (aRequest.type != "geolocation")
|
||||
return;
|
||||
|
||||
let pm = Services.perms;
|
||||
let result = pm.testExactPermission(aRequest.requestingURI, "geo");
|
||||
let result = pm.testExactPermission(aRequest.uri, "geo");
|
||||
|
||||
if (result == Ci.nsIPermissionManager.ALLOW_ACTION) {
|
||||
aRequest.allow();
|
||||
|
@ -29,17 +32,17 @@ GeolocationPrompt.prototype = {
|
|||
function setPagePermission(aUri, aAllow) {
|
||||
let contentPrefs = Services.contentPrefs;
|
||||
|
||||
if (!contentPrefs.hasPref(aRequest.requestingURI, "geo.request.remember"))
|
||||
contentPrefs.setPref(aRequest.requestingURI, "geo.request.remember", 0);
|
||||
if (!contentPrefs.hasPref(aRequest.uri, "geo.request.remember"))
|
||||
contentPrefs.setPref(aRequest.uri, "geo.request.remember", 0);
|
||||
|
||||
let count = contentPrefs.getPref(aRequest.requestingURI, "geo.request.remember");
|
||||
let count = contentPrefs.getPref(aRequest.uri, "geo.request.remember");
|
||||
|
||||
if (aAllow == false)
|
||||
count--;
|
||||
else
|
||||
count++;
|
||||
|
||||
contentPrefs.setPref(aRequest.requestingURI, "geo.request.remember", count);
|
||||
contentPrefs.setPref(aRequest.uri, "geo.request.remember", count);
|
||||
|
||||
if (count == kCountBeforeWeRemember)
|
||||
pm.add(aUri, "geo", Ci.nsIPermissionManager.ALLOW_ACTION);
|
||||
|
@ -60,12 +63,12 @@ GeolocationPrompt.prototype = {
|
|||
}
|
||||
|
||||
let notificationBox = null;
|
||||
if (aRequest.requestingWindow) {
|
||||
let requestingWindow = aRequest.requestingWindow.top;
|
||||
if (aRequest.window) {
|
||||
let requestingWindow = aRequest.window.top;
|
||||
let chromeWin = getChromeWindow(requestingWindow).wrappedJSObject;
|
||||
notificationBox = chromeWin.getNotificationBox(requestingWindow);
|
||||
} else {
|
||||
let chromeWin = aRequest.requestingElement.ownerDocument.defaultView;
|
||||
let chromeWin = aRequest.element.ownerDocument.defaultView;
|
||||
notificationBox = chromeWin.Browser.getNotificationBox();
|
||||
}
|
||||
|
||||
|
@ -77,7 +80,7 @@ GeolocationPrompt.prototype = {
|
|||
label: browserBundle.GetStringFromName("geolocation.share"),
|
||||
accessKey: null,
|
||||
callback: function(notification) {
|
||||
setPagePermission(aRequest.requestingURI, true);
|
||||
setPagePermission(aRequest.uri, true);
|
||||
aRequest.allow();
|
||||
},
|
||||
},
|
||||
|
@ -85,13 +88,13 @@ GeolocationPrompt.prototype = {
|
|||
label: browserBundle.GetStringFromName("geolocation.dontShare"),
|
||||
accessKey: null,
|
||||
callback: function(notification) {
|
||||
setPagePermission(aRequest.requestingURI, false);
|
||||
setPagePermission(aRequest.uri, false);
|
||||
aRequest.cancel();
|
||||
},
|
||||
}];
|
||||
|
||||
let message = browserBundle.formatStringFromName("geolocation.siteWantsToKnow",
|
||||
[aRequest.requestingURI.host], 1);
|
||||
[aRequest.uri.host], 1);
|
||||
|
||||
let newBar = notificationBox.appendNotification(message,
|
||||
"geolocation",
|
||||
|
@ -106,4 +109,4 @@ GeolocationPrompt.prototype = {
|
|||
|
||||
|
||||
//module initialization
|
||||
const NSGetFactory = XPCOMUtils.generateNSGetFactory([GeolocationPrompt]);
|
||||
const NSGetFactory = XPCOMUtils.generateNSGetFactory([ContentPermissionPrompt]);
|
|
@ -37,8 +37,14 @@
|
|||
const Cc = Components.classes;
|
||||
const Ci = Components.interfaces;
|
||||
const Cu = Components.utils;
|
||||
const Cr = Components.results;
|
||||
|
||||
const PREF_BD_USEDOWNLOADDIR = "browser.download.useDownloadDir";
|
||||
#ifdef ANDROID
|
||||
const URI_GENERIC_ICON_DOWNLOAD = "drawable://alertdownloads";
|
||||
#else
|
||||
const URI_GENERIC_ICON_DOWNLOAD = "chrome://browser/skin/images/alert-downloads-30.png";
|
||||
#endif
|
||||
|
||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
|
@ -59,13 +65,28 @@ HelperAppLauncherDialog.prototype = {
|
|||
aLauncher.MIMEInfo.preferredAction = Ci.nsIMIMEInfo.useSystemDefault;
|
||||
aLauncher.launchWithApplication(null, false);
|
||||
} else {
|
||||
aLauncher.saveToDisk(null, false);
|
||||
let wasClicked = false;
|
||||
let listener = {
|
||||
observe: function(aSubject, aTopic, aData) {
|
||||
if (aTopic == "alertclickcallback") {
|
||||
wasClicked = true;
|
||||
let win = Cc["@mozilla.org/appshell/window-mediator;1"].getService(Ci.nsIWindowMediator).getMostRecentWindow("navigator:browser");
|
||||
if (win)
|
||||
win.BrowserUI.showPanel("downloads-container");
|
||||
|
||||
aLauncher.saveToDisk(null, false);
|
||||
} else {
|
||||
if (!wasClicked)
|
||||
aLauncher.cancel(Cr.NS_BINDING_ABORTED);
|
||||
}
|
||||
}
|
||||
};
|
||||
this._notify(aLauncher, listener);
|
||||
}
|
||||
},
|
||||
|
||||
promptForSaveToFile: function hald_promptForSaveToFile(aLauncher, aContext, aDefaultFile, aSuggestedFileExt, aForcePrompt) {
|
||||
let file = null;
|
||||
|
||||
let prefs = Services.prefs;
|
||||
|
||||
if (!aForcePrompt) {
|
||||
|
@ -94,7 +115,7 @@ HelperAppLauncherDialog.prototype = {
|
|||
}
|
||||
|
||||
// Use file picker to show dialog.
|
||||
let picker = Components.classes["@mozilla.org/filepicker;1"].createInstance(Ci.nsIFilePicker);
|
||||
let picker = Cc["@mozilla.org/filepicker;1"].createInstance(Ci.nsIFilePicker);
|
||||
let windowTitle = "";
|
||||
let parent = aContext.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowInternal);
|
||||
picker.init(parent, windowTitle, Ci.nsIFilePicker.modeSave);
|
||||
|
@ -197,24 +218,34 @@ HelperAppLauncherDialog.prototype = {
|
|||
aLocalFile.leafName = aLocalFile.leafName.replace(/^(.*\()\d+\)/, "$1" + (collisionCount+1) + ")");
|
||||
}
|
||||
}
|
||||
aLocalFile.create(Components.interfaces.nsIFile.NORMAL_FILE_TYPE, 0600);
|
||||
aLocalFile.create(Ci.nsIFile.NORMAL_FILE_TYPE, 0600);
|
||||
}
|
||||
catch (e) {
|
||||
dump("*** exception in validateLeafName: " + e + "\n");
|
||||
|
||||
if (e.result == Components.results.NS_ERROR_FILE_ACCESS_DENIED)
|
||||
if (e.result == Cr.NS_ERROR_FILE_ACCESS_DENIED)
|
||||
throw e;
|
||||
|
||||
if (aLocalFile.leafName == "" || aLocalFile.isDirectory()) {
|
||||
aLocalFile.append("unnamed");
|
||||
if (aLocalFile.exists())
|
||||
aLocalFile.createUnique(Components.interfaces.nsIFile.NORMAL_FILE_TYPE, 0600);
|
||||
aLocalFile.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, 0600);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
isUsableDirectory: function hald_isUsableDirectory(aDirectory) {
|
||||
return aDirectory.exists() && aDirectory.isDirectory() && aDirectory.isWritable();
|
||||
},
|
||||
|
||||
_notify: function hald_notify(aLauncher, aCallback) {
|
||||
let bundle = Services.strings.createBundle("chrome://browser/locale/browser.properties");
|
||||
|
||||
let notifier = Cc["@mozilla.org/alerts-service;1"].getService(Ci.nsIAlertsService);
|
||||
notifier.showAlertNotification(URI_GENERIC_ICON_DOWNLOAD,
|
||||
bundle.GetStringFromName("alertDownloads"),
|
||||
bundle.GetStringFromName("alertCantOpenDownload"),
|
||||
true, "", aCallback, "downloadopen-fail");
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -52,7 +52,9 @@ XPIDLSRCS = \
|
|||
|
||||
EXTRA_PP_COMPONENTS = \
|
||||
AboutRedirector.js \
|
||||
BrowserCLH.js \
|
||||
DirectoryProvider.js\
|
||||
HelperAppDialog.js \
|
||||
Sidebar.js \
|
||||
SessionStore.js \
|
||||
$(NULL)
|
||||
|
@ -60,12 +62,10 @@ EXTRA_PP_COMPONENTS = \
|
|||
EXTRA_COMPONENTS = \
|
||||
MobileComponents.manifest \
|
||||
BrowserStartup.js \
|
||||
GeolocationPrompt.js \
|
||||
ContentPermissionPrompt.js \
|
||||
XPIDialogService.js \
|
||||
DownloadManagerUI.js \
|
||||
HelperAppDialog.js \
|
||||
PromptService.js \
|
||||
BrowserCLH.js \
|
||||
ContentDispatchChooser.js \
|
||||
AutoCompleteCache.js \
|
||||
AddonUpdateService.js \
|
||||
|
|
|
@ -37,9 +37,9 @@ category app-startup BrowserStartup service,@mozilla.org/browser/browser-startup
|
|||
category agent-style-sheets browser-content-stylesheet chrome://browser/content/content.css
|
||||
category agent-style-sheets browser-cursor-stylesheet chrome://browser/content/cursor.css
|
||||
|
||||
# GeolocationPrompt.js
|
||||
component {C6E8C44D-9F39-4AF7-BCC0-76E38A8310F5} GeolocationPrompt.js
|
||||
contract @mozilla.org/geolocation/prompt;1 {C6E8C44D-9F39-4AF7-BCC0-76E38A8310F5}
|
||||
# ContentPermissionPrompt.js
|
||||
component {C6E8C44D-9F39-4AF7-BCC0-76E38A8310F5} ContentPermissionPrompt.js
|
||||
contract @mozilla.org/content-permission/prompt;1 {C6E8C44D-9F39-4AF7-BCC0-76E38A8310F5}
|
||||
|
||||
# AlertsService.js
|
||||
component {fe33c107-82a4-41d6-8c64-5353267e04c9} AlertsService.js
|
||||
|
|
|
@ -60,12 +60,11 @@ function PromptService() {
|
|||
case "Prompt:Call":
|
||||
// List of methods we remote - to check against malicious data.
|
||||
// For example, it would be dangerous to allow content to show
|
||||
// auth prompts. We allow only the methods that web content
|
||||
// is allowed to show.
|
||||
const ALL_METHODS = ['alert', 'confirm', 'prompt'];
|
||||
// auth prompts.
|
||||
const ALL_METHODS = ["alert", "alertCheck", "confirm", "prompt", "confirmEx", "confirmCheck", "select"];
|
||||
var method = aMessage.json.method;
|
||||
if (ALL_METHODS.indexOf(method) == -1)
|
||||
throw 'PromptServiceRemoter received an invalid method';
|
||||
throw "PromptServiceRemoter received an invalid method "+method;
|
||||
var arguments = aMessage.json.arguments;
|
||||
arguments.unshift(null); // No need for window, child is already on top
|
||||
// (see mobile browser's PromptService.js)
|
||||
|
|
|
@ -89,6 +89,7 @@ alertAddonsDisabled=#1 incompatible add-on was disabled;#1 incompatible add-ons
|
|||
alertDownloads=Downloads
|
||||
alertDownloadsStart=Downloading: %S
|
||||
alertDownloadsDone=%S has finished downloading
|
||||
alertCantOpenDownload=Can't open file. Tap to save it.
|
||||
|
||||
# Notifications
|
||||
notificationRestart.normal=Restart to complete changes.
|
||||
|
|
|
@ -669,7 +669,7 @@ placelist[ui="manage"] placeitem[type="folder"] {
|
|||
background-image: none;
|
||||
}
|
||||
|
||||
placeitem[type="folder"] > .bookmark-item-label > image,
|
||||
placeitem[type="folder"] > .bookmark-item-container > image,
|
||||
placeitem[type="folder"] > .bookmark-manage > image {
|
||||
list-style-image: url(images/folder-32.png);
|
||||
margin-top: 0;
|
||||
|
@ -757,17 +757,21 @@ historylist placeitem:active:not([selected="true"]):not([class="remotetabs-item-
|
|||
background-color: #8db8d8;
|
||||
}
|
||||
|
||||
.autocomplete-item-label,
|
||||
.bookmark-item-label {
|
||||
.autocomplete-item-container,
|
||||
.bookmark-item-container {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.autocomplete-item-label,
|
||||
.bookmark-item-label {
|
||||
font-size: 24px !important;
|
||||
font-weight: normal;
|
||||
-moz-margin-end: 8px;
|
||||
}
|
||||
|
||||
.autocomplete-item-label > image,
|
||||
.bookmark-item-label > image,
|
||||
.autocomplete-item-container > image,
|
||||
.bookmark-item-container > image,
|
||||
placeitem > .bookmark-manage > image {
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
|
@ -779,35 +783,24 @@ placeitem > .bookmark-manage > image {
|
|||
-moz-margin-start: 8px;
|
||||
}
|
||||
|
||||
.autocomplete-item-label > image[src=""],
|
||||
placeitem[src=""] .bookmark-item-label > image {
|
||||
.autocomplete-item-container > image[src=""],
|
||||
placeitem[src=""] .bookmark-item-container > image {
|
||||
list-style-image: url(chrome://mozapps/skin/places/defaultFavicon.png);
|
||||
}
|
||||
|
||||
.autocomplete-item-label > vbox > label,
|
||||
.bookmark-item-label > vbox > label {
|
||||
.autocomplete-item-container > vbox > label,
|
||||
.bookmark-item-container > vbox > label {
|
||||
-moz-margin-start: 1px;
|
||||
}
|
||||
|
||||
.autocomplete-item-label[favorite="true"] {
|
||||
-moz-padding-end: 30px;
|
||||
.autocomplete-item-container[favorite="true"] {
|
||||
background: url(images/star-24.png) no-repeat 100% 2px;
|
||||
}
|
||||
|
||||
.autocomplete-item-label[favorite="true"]:-moz-locale-dir(rtl) {
|
||||
.autocomplete-item-container[favorite="true"]:-moz-locale-dir(rtl) {
|
||||
background: url(images/star-24.png) no-repeat left 2px;
|
||||
}
|
||||
|
||||
.autocomplete-item-label:not([tags=""]):after,
|
||||
.bookmark-item-label:not([tags=""]):after {
|
||||
float: right;
|
||||
content: attr(tags);
|
||||
font-size: 18px !important;
|
||||
font-weight: lighter;
|
||||
padding-top: 4px;
|
||||
-moz-margin-start: 8px;
|
||||
}
|
||||
|
||||
.autocomplete-item-url,
|
||||
.bookmark-item-url {
|
||||
color: blue;
|
||||
|
@ -815,6 +808,44 @@ placeitem[src=""] .bookmark-item-label > image {
|
|||
-moz-margin-end: 24px;
|
||||
}
|
||||
|
||||
.autocomplete-item-container[favorite="true"] .autocomplete-item-label {
|
||||
-moz-padding-end: 30px;
|
||||
}
|
||||
|
||||
.autocomplete-item-tags,
|
||||
.bookmark-item-tags {
|
||||
content: attr(tags);
|
||||
font-size: 18px !important;
|
||||
font-weight: lighter;
|
||||
margin: 2px 0 4px 0px;
|
||||
-moz-margin-start: 8px;
|
||||
-moz-padding-end: 32px;
|
||||
}
|
||||
|
||||
.autocomplete-item-tags[value=""] {
|
||||
visibility: hidden;
|
||||
}
|
||||
|
||||
.autocomplete-item-badge {
|
||||
opacity: 1;
|
||||
-moz-transition: opacity 1s ease;
|
||||
background-color: #c90707;
|
||||
border: 1px solid #951919;
|
||||
-moz-border-radius: 2px;
|
||||
content: attr(badge);
|
||||
font-size: 12px !important;
|
||||
font-weight: bolder;
|
||||
margin: 4px 0 0 0;
|
||||
padding: 4px 6px;
|
||||
color: white;
|
||||
}
|
||||
|
||||
autocompleteresult:not([badge]) .autocomplete-item-badge,
|
||||
.autocomplete-item-badge[value=""] {
|
||||
opacity: 0;
|
||||
-moz-transition: none;
|
||||
}
|
||||
|
||||
/* special "no results", "awesome header row" and "title rows" items */
|
||||
autocompleteresult[class="history-item-title"],
|
||||
autocompleteresult[class="remotetabs-item-title"] {
|
||||
|
@ -828,8 +859,8 @@ autocompleteresult[class="remotetabs-item-title"] .bookmark-item-url {
|
|||
display: none;
|
||||
}
|
||||
|
||||
autocompleteresult[class="history-item-title"] .bookmark-item-label,
|
||||
autocompleteresult[class="remotetabs-item-title"] .bookmark-item-label {
|
||||
autocompleteresult[class="history-item-title"] .bookmark-item-container,
|
||||
autocompleteresult[class="remotetabs-item-title"] .bookmark-item-container {
|
||||
font-size: 24px !important;
|
||||
}
|
||||
|
||||
|
@ -847,7 +878,7 @@ autocompleteresult.noresults:active {
|
|||
background-color: white;
|
||||
}
|
||||
|
||||
autocompleteresult.noresults > .autocomplete-item-label {
|
||||
autocompleteresult.noresults > .autocomplete-item-container {
|
||||
text-align: center;
|
||||
color: grey;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче