Bug 334486: Ability to restore shipped search engines after they've been removed, patch by Michael Wu <michael.wu@mozilla.com>, r=mconnor

This commit is contained in:
gavin%gavinsharp.com 2006-07-05 19:09:38 +00:00
Родитель 6dbaaf05f4
Коммит 930cb04984
5 изменённых файлов: 31 добавлений и 3 удалений

Просмотреть файл

@ -82,6 +82,13 @@ function disableAddons() {
prefB.clearUserPref("general.skins.selectedSkin");
}
function restoreDefaultSearchEngines() {
var searchService = Components.classes["@mozilla.org/browser/search-service;1"]
.getService(Components.interfaces.nsIBrowserSearchService);
searchService.restoreDefaultEngines();
}
function onOK() {
try {
if (document.getElementById("resetUserPrefs").checked)
@ -92,6 +99,8 @@ function onOK() {
deleteLocalstore();
if (document.getElementById("disableAddons").checked)
disableAddons();
if (document.getElementById("restoreSearch").checked)
restoreDefaultSearchEngines();
} catch(e) {
}
@ -114,5 +123,6 @@ function UpdateOKButtonState() {
!document.getElementById("resetUserPrefs").checked &&
!document.getElementById("resetBookmarks").checked &&
!document.getElementById("resetToolbars").checked &&
!document.getElementById("disableAddons").checked;
!document.getElementById("disableAddons").checked &&
!document.getElementById("restoreSearch").checked;
}

Просмотреть файл

@ -81,6 +81,7 @@
<checkbox id="resetToolbars" label="&resetToolbars.label;" accesskey="&resetToolbars.accesskey;"/>
<checkbox id="resetBookmarks" label="&resetBookmarks.label;" accesskey="&resetBookmarks.accesskey;"/>
<checkbox id="resetUserPrefs" label="&resetUserPrefs.label;" accesskey="&resetUserPrefs.accesskey;"/>
<checkbox id="restoreSearch" label="&restoreSearch.label;" accesskey="&restoreSearch.accesskey;"/>
</vbox>
<separator class="thin"/>

Просмотреть файл

@ -162,7 +162,7 @@ interface nsISearchEngine : nsISupports
};
[scriptable, uuid(89a503ac-ea67-4bad-89f9-aa2b06140702)]
[scriptable, uuid(019c7025-0e26-48d0-b2a4-97cc7e0296cf)]
interface nsIBrowserSearchService : nsISupports
{
/**
@ -223,6 +223,12 @@ interface nsIBrowserSearchService : nsISupports
in AString method,
in AString url);
/**
* Un-hides all engines installed in the directory corresponding to
* the directory service's NS_APP_SEARCH_DIR key.
*/
void restoreDefaultEngines();
/**
* Returns an engine with the specified alias.
*

Просмотреть файл

@ -21,7 +21,7 @@
# Contributor(s):
# Ben Goodger <beng@google.com> (Original author)
# Gavin Sharp <gavin@gavinsharp.com>
# Joe Hughes <joe@retrovirus.com
# Joe Hughes <joe@retrovirus.com>
# Pamela Greene <pamg.bugs@gmail.com>
#
# Alternatively, the contents of this file may be used under the terms of
@ -2429,6 +2429,14 @@ SearchService.prototype = {
notifyAction(engine, SEARCH_ENGINE_CHANGED);
},
restoreDefaultEngines: function SRCH_SVC_resetDefaultEngines() {
for each (var e in this._engines) {
// Unhide all appdir-installed engines
if (e.hidden && e._isInAppDir)
e.hidden = false;
}
},
get defaultEngine() {
const defPref = BROWSER_SEARCH_PREF + "defaultenginename";
// Get the default engine - this pref should always exist, but the engine

Просмотреть файл

@ -54,5 +54,8 @@
<!ENTITY resetUserPrefs.label "Reset all user preferences to &brandShortName; defaults">
<!ENTITY resetUserPrefs.accesskey "p">
<!ENTITY restoreSearch.label "Restore default search engines">
<!ENTITY restoreSearch.accesskey "s">
<!ENTITY changeAndRestartButton.label "Make Changes and Restart">
<!ENTITY continueButton.label "Continue in Safe Mode">