mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-05 05:30:29 +00:00
merge fx-team to mozilla-central a=merge
This commit is contained in:
commit
958900994a
@ -289,15 +289,6 @@ if (typeof Mozilla == 'undefined') {
|
|||||||
_sendEvent('toggleReaderMode');
|
_sendEvent('toggleReaderMode');
|
||||||
};
|
};
|
||||||
|
|
||||||
Mozilla.UITour.setDefaultBrowser = function() {
|
|
||||||
_sendEvent('setDefaultBrowser');
|
|
||||||
}
|
|
||||||
|
|
||||||
Mozilla.UITour.isDefaultBrowser = function(callback) {
|
|
||||||
_sendEvent('isDefaultBrowser', {
|
|
||||||
callbackID: _waitForCallback(callback),
|
|
||||||
});
|
|
||||||
}
|
|
||||||
})();
|
})();
|
||||||
|
|
||||||
// Make this library Require-able.
|
// Make this library Require-able.
|
||||||
|
@ -615,7 +615,7 @@ this.UITour = {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.setConfiguration(data.configuration, data.value);
|
this.setConfiguration(window, data.configuration, data.value);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -718,21 +718,6 @@ this.UITour = {
|
|||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case "setDefaultBrowser": {
|
|
||||||
let shell = Components.classes["@mozilla.org/browser/shell-service;1"]
|
|
||||||
.getService(Components.interfaces.nsIShellService);
|
|
||||||
shell.setDefaultBrowser(true, false);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case "isDefaultBrowser": {
|
|
||||||
let shell = Components.classes["@mozilla.org/browser/shell-service;1"]
|
|
||||||
.getService(Components.interfaces.nsIShellService);
|
|
||||||
let isDefault = shell.isDefaultBrowser(false);
|
|
||||||
this.sendPageCallback(messageManager, data.callbackID, { value: isDefault });
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this.tourBrowsersByWindow.has(window)) {
|
if (!this.tourBrowsersByWindow.has(window)) {
|
||||||
@ -1729,6 +1714,14 @@ this.UITour = {
|
|||||||
let props = ["defaultUpdateChannel", "version"];
|
let props = ["defaultUpdateChannel", "version"];
|
||||||
let appinfo = {};
|
let appinfo = {};
|
||||||
props.forEach(property => appinfo[property] = Services.appinfo[property]);
|
props.forEach(property => appinfo[property] = Services.appinfo[property]);
|
||||||
|
let isDefaultBrowser = null;
|
||||||
|
try {
|
||||||
|
let shell = aWindow.getShellService();
|
||||||
|
if (shell) {
|
||||||
|
isDefaultBrowser = shell.isDefaultBrowser(false);
|
||||||
|
}
|
||||||
|
} catch (e) {}
|
||||||
|
appinfo["defaultBrowser"] = isDefaultBrowser;
|
||||||
this.sendPageCallback(aMessageManager, aCallbackID, appinfo);
|
this.sendPageCallback(aMessageManager, aCallbackID, appinfo);
|
||||||
break;
|
break;
|
||||||
case "availableTargets":
|
case "availableTargets":
|
||||||
@ -1763,8 +1756,18 @@ this.UITour = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
setConfiguration: function(aConfiguration, aValue) {
|
setConfiguration: function(aWindow, aConfiguration, aValue) {
|
||||||
switch (aConfiguration) {
|
switch (aConfiguration) {
|
||||||
|
case "defaultBrowser":
|
||||||
|
// Ignore aValue in this case because the default browser can only
|
||||||
|
// be set, not unset.
|
||||||
|
try {
|
||||||
|
let shell = aWindow.getShellService();
|
||||||
|
if (shell) {
|
||||||
|
shell.setDefaultBrowser(true, false);
|
||||||
|
}
|
||||||
|
} catch (e) {}
|
||||||
|
break;
|
||||||
case "Loop:ResumeTourOnFirstJoin":
|
case "Loop:ResumeTourOnFirstJoin":
|
||||||
// Ignore aValue in this case to avoid accidentally setting it to false.
|
// Ignore aValue in this case to avoid accidentally setting it to false.
|
||||||
Services.prefs.setBoolPref("loop.gettingStarted.resumeOnFirstJoin", true);
|
Services.prefs.setBoolPref("loop.gettingStarted.resumeOnFirstJoin", true);
|
||||||
|
@ -48,7 +48,7 @@ let tests = [
|
|||||||
is not actually replacing the original ShellService.
|
is not actually replacing the original ShellService.
|
||||||
taskify(function* test_setDefaultBrowser() {
|
taskify(function* test_setDefaultBrowser() {
|
||||||
try {
|
try {
|
||||||
gContentAPI.setDefaultBrowser();
|
gContentAPI.setConfiguration("defaultBrowser");
|
||||||
ok(setDefaultBrowserCalled, "setDefaultBrowser called");
|
ok(setDefaultBrowserCalled, "setDefaultBrowser called");
|
||||||
} finally {
|
} finally {
|
||||||
mockShellService.unregister();
|
mockShellService.unregister();
|
||||||
@ -60,8 +60,8 @@ let tests = [
|
|||||||
let shell = Components.classes["@mozilla.org/browser/shell-service;1"]
|
let shell = Components.classes["@mozilla.org/browser/shell-service;1"]
|
||||||
.getService(Components.interfaces.nsIShellService);
|
.getService(Components.interfaces.nsIShellService);
|
||||||
let isDefault = shell.isDefaultBrowser(false);
|
let isDefault = shell.isDefaultBrowser(false);
|
||||||
gContentAPI.isDefaultBrowser(function(data) {
|
gContentAPI.getConfiguration("appinfo", (data) => {
|
||||||
is(data.value, isDefault, "gContentAPI.isDefaultBrowser should match shellService.isDefaultBrowser");
|
is(data.value, data.defaultBrowser, "gContentAPI result should match shellService.isDefaultBrowser");
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
@ -765,6 +765,13 @@ namespace places {
|
|||||||
do_CreateInstance("@mozilla.org/variant;1");
|
do_CreateInstance("@mozilla.org/variant;1");
|
||||||
NS_ENSURE_STATE(result);
|
NS_ENSURE_STATE(result);
|
||||||
|
|
||||||
|
if (StringBeginsWith(src, NS_LITERAL_STRING("http://")))
|
||||||
|
src.Cut(0, 7);
|
||||||
|
else if (StringBeginsWith(src, NS_LITERAL_STRING("https://")))
|
||||||
|
src.Cut(0, 8);
|
||||||
|
else if (StringBeginsWith(src, NS_LITERAL_STRING("ftp://")))
|
||||||
|
src.Cut(0, 6);
|
||||||
|
|
||||||
// Remove common URL hostname prefixes
|
// Remove common URL hostname prefixes
|
||||||
if (StringBeginsWith(src, NS_LITERAL_STRING("www."))) {
|
if (StringBeginsWith(src, NS_LITERAL_STRING("www."))) {
|
||||||
src.Cut(0, 4);
|
src.Cut(0, 4);
|
||||||
|
@ -51,7 +51,6 @@ const MATCH_BEGINNING_CASE_SENSITIVE = Ci.mozIPlacesAutoComplete.MATCH_BEGINNING
|
|||||||
const QUERYTYPE_FILTERED = 0;
|
const QUERYTYPE_FILTERED = 0;
|
||||||
const QUERYTYPE_AUTOFILL_HOST = 1;
|
const QUERYTYPE_AUTOFILL_HOST = 1;
|
||||||
const QUERYTYPE_AUTOFILL_URL = 2;
|
const QUERYTYPE_AUTOFILL_URL = 2;
|
||||||
const QUERYTYPE_AUTOFILL_PREDICTURL = 3;
|
|
||||||
|
|
||||||
// This separator is used as an RTL-friendly way to split the title and tags.
|
// This separator is used as an RTL-friendly way to split the title and tags.
|
||||||
// It can also be used by an nsIAutoCompleteResult consumer to re-split the
|
// It can also be used by an nsIAutoCompleteResult consumer to re-split the
|
||||||
@ -212,22 +211,18 @@ const SQL_BOOKMARKED_HOST_QUERY = bookmarkedHostQuery();
|
|||||||
const SQL_BOOKMARKED_TYPED_HOST_QUERY = bookmarkedHostQuery("AND typed = 1");
|
const SQL_BOOKMARKED_TYPED_HOST_QUERY = bookmarkedHostQuery("AND typed = 1");
|
||||||
|
|
||||||
function urlQuery(conditions = "") {
|
function urlQuery(conditions = "") {
|
||||||
let query =
|
return `/* do not warn (bug no): cannot use an index to sort */
|
||||||
`/* do not warn (bug no): cannot use an index */
|
|
||||||
SELECT :query_type, h.url, NULL, f.url AS favicon_url,
|
SELECT :query_type, h.url, NULL, f.url AS favicon_url,
|
||||||
foreign_count > 0 AS bookmarked,
|
foreign_count > 0 AS bookmarked,
|
||||||
NULL, NULL, NULL, NULL, NULL, NULL, h.frecency
|
NULL, NULL, NULL, NULL, NULL, NULL, h.frecency
|
||||||
FROM moz_places h
|
FROM moz_places h
|
||||||
LEFT JOIN moz_favicons f ON h.favicon_id = f.id
|
LEFT JOIN moz_favicons f ON h.favicon_id = f.id
|
||||||
WHERE h.frecency <> 0
|
WHERE (rev_host = :revHost OR rev_host = :revHost || "www.")
|
||||||
|
AND h.frecency <> 0
|
||||||
|
AND fixup_url(h.url) BETWEEN :searchString AND :searchString || X'FFFF'
|
||||||
${conditions}
|
${conditions}
|
||||||
AND AUTOCOMPLETE_MATCH(:searchString, h.url,
|
|
||||||
h.title, '',
|
|
||||||
h.visit_count, h.typed, bookmarked, 0,
|
|
||||||
:matchBehavior, :searchBehavior)
|
|
||||||
ORDER BY h.frecency DESC, h.id DESC
|
ORDER BY h.frecency DESC, h.id DESC
|
||||||
LIMIT 1`;
|
LIMIT 1`;
|
||||||
return query;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const SQL_URL_QUERY = urlQuery();
|
const SQL_URL_QUERY = urlQuery();
|
||||||
@ -818,10 +813,7 @@ Search.prototype = {
|
|||||||
let shouldAutofill = this._shouldAutofill;
|
let shouldAutofill = this._shouldAutofill;
|
||||||
if (this.pending && !hasFirstResult && shouldAutofill) {
|
if (this.pending && !hasFirstResult && shouldAutofill) {
|
||||||
// It may also look like a URL we know from the database.
|
// It may also look like a URL we know from the database.
|
||||||
// Here we can only try to predict whether the URL autofill query is
|
hasFirstResult = yield this._matchKnownUrl(conn);
|
||||||
// likely to return a result. If the prediction ends up being wrong,
|
|
||||||
// later we will need to make up for the lack of a special first result.
|
|
||||||
hasFirstResult = yield this._matchKnownUrl(conn, queries);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.pending && !hasFirstResult && shouldAutofill) {
|
if (this.pending && !hasFirstResult && shouldAutofill) {
|
||||||
@ -832,11 +824,21 @@ Search.prototype = {
|
|||||||
if (this.pending && this._enableActions && !hasFirstResult) {
|
if (this.pending && this._enableActions && !hasFirstResult) {
|
||||||
// If we don't have a result that matches what we know about, then
|
// If we don't have a result that matches what we know about, then
|
||||||
// we use a fallback for things we don't know about.
|
// we use a fallback for things we don't know about.
|
||||||
yield this._matchHeuristicFallback();
|
|
||||||
|
// We may not have auto-filled, but this may still look like a URL.
|
||||||
|
// However, even if the input is a valid URL, we may not want to use
|
||||||
|
// it as such. This can happen if the host would require whitelisting,
|
||||||
|
// but isn't in the whitelist.
|
||||||
|
hasFirstResult = yield this._matchUnknownUrl();
|
||||||
}
|
}
|
||||||
|
|
||||||
// IMPORTANT: No other first result heuristics should run after
|
if (this.pending && this._enableActions && !hasFirstResult) {
|
||||||
// _matchHeuristicFallback().
|
// When all else fails, we search using the current search engine.
|
||||||
|
hasFirstResult = yield this._matchCurrentSearchEngine();
|
||||||
|
}
|
||||||
|
|
||||||
|
// IMPORTANT: No other first result heuristics should run after this point.
|
||||||
|
|
||||||
yield this._sleep(Prefs.delay);
|
yield this._sleep(Prefs.delay);
|
||||||
if (!this.pending)
|
if (!this.pending)
|
||||||
return;
|
return;
|
||||||
@ -846,15 +848,7 @@ Search.prototype = {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
for (let [query, params] of queries) {
|
for (let [query, params] of queries) {
|
||||||
let hasResult = yield conn.executeCached(query, params, this._onResultRow.bind(this));
|
yield conn.executeCached(query, params, this._onResultRow.bind(this));
|
||||||
|
|
||||||
if (this.pending && this._enableActions && !hasResult &&
|
|
||||||
params.query_type == QUERYTYPE_AUTOFILL_URL) {
|
|
||||||
// If we predicted that our URL autofill query might have gotten a
|
|
||||||
// result, but it didn't, then we need to recover.
|
|
||||||
yield this._matchHeuristicFallback();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!this.pending)
|
if (!this.pending)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -908,7 +902,7 @@ Search.prototype = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
_matchKnownUrl: function* (conn, queries) {
|
_matchKnownUrl: function* (conn) {
|
||||||
// Hosts have no "/" in them.
|
// Hosts have no "/" in them.
|
||||||
let lastSlashIndex = this._searchString.lastIndexOf("/");
|
let lastSlashIndex = this._searchString.lastIndexOf("/");
|
||||||
// Search only URLs if there's a slash in the search string...
|
// Search only URLs if there's a slash in the search string...
|
||||||
@ -921,14 +915,13 @@ Search.prototype = {
|
|||||||
// assuming that if we get a result from a *host* query and it *looks*
|
// assuming that if we get a result from a *host* query and it *looks*
|
||||||
// like a URL, then we'll probably have a result.
|
// like a URL, then we'll probably have a result.
|
||||||
let gotResult = false;
|
let gotResult = false;
|
||||||
let [ query, params ] = this._urlPredictQuery;
|
let [ query, params ] = this._urlQuery;
|
||||||
yield conn.executeCached(query, params, row => {
|
yield conn.executeCached(query, params, row => {
|
||||||
gotResult = true;
|
gotResult = true;
|
||||||
queries.unshift(this._urlQuery);
|
this._onResultRow(row);
|
||||||
});
|
});
|
||||||
return gotResult;
|
return gotResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -938,7 +931,6 @@ Search.prototype = {
|
|||||||
gotResult = true;
|
gotResult = true;
|
||||||
this._onResultRow(row);
|
this._onResultRow(row);
|
||||||
});
|
});
|
||||||
|
|
||||||
return gotResult;
|
return gotResult;
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -1042,10 +1034,11 @@ Search.prototype = {
|
|||||||
_matchCurrentSearchEngine: function* () {
|
_matchCurrentSearchEngine: function* () {
|
||||||
let match = yield PlacesSearchAutocompleteProvider.getDefaultMatch();
|
let match = yield PlacesSearchAutocompleteProvider.getDefaultMatch();
|
||||||
if (!match)
|
if (!match)
|
||||||
return;
|
return false;
|
||||||
|
|
||||||
let query = this._originalSearchString;
|
let query = this._originalSearchString;
|
||||||
this._addSearchEngineMatch(match, query);
|
this._addSearchEngineMatch(match, query);
|
||||||
|
return true;
|
||||||
},
|
},
|
||||||
|
|
||||||
_addSearchEngineMatch(match, query, suggestion) {
|
_addSearchEngineMatch(match, query, suggestion) {
|
||||||
@ -1071,23 +1064,6 @@ Search.prototype = {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
// These are separated out so we can run them in two distinct cases:
|
|
||||||
// (1) We didn't match on anything that we know about
|
|
||||||
// (2) Our predictive query for URL autofill thought we may get a result,
|
|
||||||
// but we didn't.
|
|
||||||
_matchHeuristicFallback: function* () {
|
|
||||||
// We may not have auto-filled, but this may still look like a URL.
|
|
||||||
let hasFirstResult = yield this._matchUnknownUrl();
|
|
||||||
// However, even if the input is a valid URL, we may not want to use
|
|
||||||
// it as such. This can happen if the host would require whitelisting,
|
|
||||||
// but isn't in the whitelist.
|
|
||||||
|
|
||||||
if (this.pending && !hasFirstResult) {
|
|
||||||
// When all else fails, we search using the current search engine.
|
|
||||||
yield this._matchCurrentSearchEngine();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
// TODO (bug 1054814): Use visited URLs to inform which scheme to use, if the
|
// TODO (bug 1054814): Use visited URLs to inform which scheme to use, if the
|
||||||
// scheme isn't specificed.
|
// scheme isn't specificed.
|
||||||
_matchUnknownUrl: function* () {
|
_matchUnknownUrl: function* () {
|
||||||
@ -1157,8 +1133,6 @@ Search.prototype = {
|
|||||||
switch (queryType) {
|
switch (queryType) {
|
||||||
case QUERYTYPE_AUTOFILL_HOST:
|
case QUERYTYPE_AUTOFILL_HOST:
|
||||||
this._result.setDefaultIndex(0);
|
this._result.setDefaultIndex(0);
|
||||||
// Fall through.
|
|
||||||
case QUERYTYPE_AUTOFILL_PREDICTURL:
|
|
||||||
match = this._processHostRow(row);
|
match = this._processHostRow(row);
|
||||||
break;
|
break;
|
||||||
case QUERYTYPE_AUTOFILL_URL:
|
case QUERYTYPE_AUTOFILL_URL:
|
||||||
@ -1555,29 +1529,6 @@ Search.prototype = {
|
|||||||
];
|
];
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
|
||||||
* Obtains a query to predict whether this._urlQuery is likely to return a
|
|
||||||
* result. We do by extracting what should be a host out of the input and
|
|
||||||
* performing a host query based on that.
|
|
||||||
*/
|
|
||||||
get _urlPredictQuery() {
|
|
||||||
// We expect this to be a full URL, not just a host. We want to extract the
|
|
||||||
// host and use that as a guess for whether we'll get a result from a URL
|
|
||||||
// query.
|
|
||||||
let slashIndex = this._searchString.indexOf("/");
|
|
||||||
|
|
||||||
let host = this._searchString.substring(0, slashIndex);
|
|
||||||
host = host.toLowerCase();
|
|
||||||
|
|
||||||
return [
|
|
||||||
SQL_HOST_QUERY,
|
|
||||||
{
|
|
||||||
query_type: QUERYTYPE_AUTOFILL_PREDICTURL,
|
|
||||||
searchString: host
|
|
||||||
}
|
|
||||||
];
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Obtains the query to search for autoFill url results.
|
* Obtains the query to search for autoFill url results.
|
||||||
*
|
*
|
||||||
@ -1585,22 +1536,15 @@ Search.prototype = {
|
|||||||
* database with and an object containing the params to bound.
|
* database with and an object containing the params to bound.
|
||||||
*/
|
*/
|
||||||
get _urlQuery() {
|
get _urlQuery() {
|
||||||
|
// We expect this to be a full URL, not just a host. We want to extract the
|
||||||
|
// host and use that as a guess for whether we'll get a result from a URL
|
||||||
|
// query.
|
||||||
|
let slashIndex = this._autofillUrlSearchString.indexOf("/");
|
||||||
|
let revHost = this._autofillUrlSearchString.substring(0, slashIndex).toLowerCase()
|
||||||
|
.split("").reverse().join("") + ".";
|
||||||
|
|
||||||
let typed = Prefs.autofillTyped || this.hasBehavior("typed");
|
let typed = Prefs.autofillTyped || this.hasBehavior("typed");
|
||||||
let bookmarked = this.hasBehavior("bookmark") && !this.hasBehavior("history");
|
let bookmarked = this.hasBehavior("bookmark") && !this.hasBehavior("history");
|
||||||
let searchBehavior = Ci.mozIPlacesAutoComplete.BEHAVIOR_URL;
|
|
||||||
|
|
||||||
// Enable searches in typed history if autofillTyped pref or typed behavior
|
|
||||||
// is true.
|
|
||||||
if (typed) {
|
|
||||||
searchBehavior |= Ci.mozIPlacesAutoComplete.BEHAVIOR_HISTORY |
|
|
||||||
Ci.mozIPlacesAutoComplete.BEHAVIOR_TYPED;
|
|
||||||
} else {
|
|
||||||
// Search in entire history.
|
|
||||||
searchBehavior |= Ci.mozIPlacesAutoComplete.BEHAVIOR_HISTORY;
|
|
||||||
}
|
|
||||||
if (bookmarked) {
|
|
||||||
searchBehavior |= Ci.mozIPlacesAutoComplete.BEHAVIOR_BOOKMARK;
|
|
||||||
}
|
|
||||||
|
|
||||||
return [
|
return [
|
||||||
bookmarked ? typed ? SQL_BOOKMARKED_TYPED_URL_QUERY
|
bookmarked ? typed ? SQL_BOOKMARKED_TYPED_URL_QUERY
|
||||||
@ -1610,8 +1554,7 @@ Search.prototype = {
|
|||||||
{
|
{
|
||||||
query_type: QUERYTYPE_AUTOFILL_URL,
|
query_type: QUERYTYPE_AUTOFILL_URL,
|
||||||
searchString: this._autofillUrlSearchString,
|
searchString: this._autofillUrlSearchString,
|
||||||
matchBehavior: MATCH_BEGINNING_CASE_SENSITIVE,
|
revHost
|
||||||
searchBehavior: searchBehavior
|
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user