зеркало из https://github.com/mozilla/gecko-dev.git
Bug 344523: AddSearchProvider doesn't check if provider already installed (installation of an engine with the same name as an already-installed engine fails silently), r=mconnor
This commit is contained in:
Родитель
afc6cd16d3
Коммит
afe9ad34c6
|
@ -1124,7 +1124,7 @@ Engine.prototype = {
|
|||
* Handle an error during the load of an engine by prompting the user to
|
||||
* notify him that the load failed.
|
||||
*/
|
||||
function onError() {
|
||||
function onError(aErrorString, aTitleString) {
|
||||
if (aEngine._engineToUpdate) {
|
||||
// We're in an update, so just fail quietly
|
||||
LOG("updating " + aEngine._engineToUpdate.name + " failed");
|
||||
|
@ -1132,11 +1132,15 @@ Engine.prototype = {
|
|||
}
|
||||
var sbs = Cc["@mozilla.org/intl/stringbundle;1"].
|
||||
getService(Ci.nsIStringBundleService);
|
||||
var searchBundle = sbs.createBundle(SEARCH_BUNDLE);
|
||||
|
||||
var brandBundle = sbs.createBundle(BRAND_BUNDLE);
|
||||
var brandName = brandBundle.GetStringFromName("brandShortName");
|
||||
var title = searchBundle.GetStringFromName("error_loading_engine_title");
|
||||
var text = searchBundle.formatStringFromName("error_loading_engine_msg2",
|
||||
|
||||
var searchBundle = sbs.createBundle(SEARCH_BUNDLE);
|
||||
var msgStringName = aErrorString || "error_loading_engine_msg2";
|
||||
var titleStringName = aTitleString || "error_loading_engine_title";
|
||||
var title = searchBundle.GetStringFromName(titleStringName);
|
||||
var text = searchBundle.formatStringFromName(msgStringName,
|
||||
[brandName, aEngine._location],
|
||||
2);
|
||||
|
||||
|
@ -1192,6 +1196,18 @@ Engine.prototype = {
|
|||
return;
|
||||
}
|
||||
|
||||
// Check to see if this is a duplicate engine. If we're confirming the
|
||||
// engine load, then we display a "this is a duplicate engine" prompt,
|
||||
// otherwise we fail silently.
|
||||
var ss = Cc["@mozilla.org/browser/search-service;1"].
|
||||
getService(Ci.nsIBrowserSearchService);
|
||||
if (ss.getEngineByName(aEngine.name)) {
|
||||
if (aEngine._confirm)
|
||||
onError("error_duplicate_engine_msg", "error_invalid_engine_title");
|
||||
LOG("_onLoad: duplicate engine found, bailing");
|
||||
return;
|
||||
}
|
||||
|
||||
// If requested, confirm the addition now that we have the title.
|
||||
if (aEngine._confirm) {
|
||||
var confirmation = aEngine._confirmAddEngine();
|
||||
|
|
|
@ -14,6 +14,8 @@ addEngineAddButtonLabel=Add
|
|||
error_loading_engine_title=Download Error
|
||||
# LOCALIZATION NOTE (error_loading_engine_msg2): %1$S = brandShortName, %2$S = location
|
||||
error_loading_engine_msg2=%S could not download the search plugin from:\n%S
|
||||
error_duplicate_engine_msg=%S could not install the search plugin from "%S" because an engine with the same name already exists.
|
||||
|
||||
error_invalid_engine_title=Install Error
|
||||
# LOCALIZATION NOTE (error_invalid_engine_msg): %S = brandShortName
|
||||
error_invalid_engine_msg=This search engine isn't supported by %S and can't be installed.
|
||||
|
|
Загрузка…
Ссылка в новой задаче