Index: browser/app/profile/firefox.js
===================================================================
RCS file: /cvsroot/mozilla/browser/app/profile/firefox.js,v
retrieving revision 1.102
diff -u -p -8 -r1.102 firefox.js
--- browser/app/profile/firefox.js 8 Mar 2006 21:54:17 -0000 1.102
+++ browser/app/profile/firefox.js 17 Mar 2006 07:08:15 -0000
@@ -200,32 +200,30 @@ pref("browser.download.manager.showWhenS
pref("browser.download.manager.useWindow", true);
pref("browser.download.manager.closeWhenDone", false);
pref("browser.download.manager.openDelay", 0);
pref("browser.download.manager.focusWhenStarting", false);
pref("browser.download.manager.flashCount", 2);
// pointer to the default engine name
pref("browser.search.defaultenginename", "chrome://browser-region/locale/region.properties");
-// pointer to the Web Search url (content area context menu)
-pref("browser.search.defaulturl", "chrome://browser-region/locale/region.properties");
+
+// disable logging for the search service by default
+pref("browser.search.log", false);
+
// Ordering of Search Engines in the Engine list.
pref("browser.search.order.1", "chrome://browser-region/locale/region.properties");
pref("browser.search.order.2", "chrome://browser-region/locale/region.properties");
pref("browser.search.param.Google.1.default", "chrome://branding/content/searchconfig.properties");
pref("browser.search.param.Google.1.custom", "chrome://branding/content/searchconfig.properties");
pref("browser.search.order.Yahoo.1", "chrome://branding/content/searchconfig.properties");
pref("browser.search.order.Yahoo.2", "chrome://branding/content/searchconfig.properties");
pref("browser.search.order.Yahoo", "chrome://branding/content/searchconfig.properties");
-// basic search popup constraint: minimum sherlock plugin version displayed
-// (note: must be a string representation of a float or it'll default to 0.0)
-pref("browser.search.basic.min_ver", "0.0");
-
// search bar results always open in a new tab
pref("browser.search.openintab", false);
// send ping to the server to update
pref("browser.search.update", true);
pref("browser.history.grouping", "day");
pref("browser.sessionhistory.max_entries", 50);
Index: browser/base/jar.mn
===================================================================
RCS file: /cvsroot/mozilla/browser/base/jar.mn,v
retrieving revision 1.99
diff -u -p -8 -r1.99 jar.mn
--- browser/base/jar.mn 14 Mar 2006 20:44:36 -0000 1.99
+++ browser/base/jar.mn 17 Mar 2006 07:08:15 -0000
@@ -26,21 +26,16 @@ browser.jar:
* content/browser/pageInfo.xul (content/pageInfo.xul)
* content/browser/pageReport.js (content/pageReport.js)
* content/browser/pageReport.xul (content/pageReport.xul)
* content/browser/pageReportFirstTime.xul (content/pageReportFirstTime.xul)
* content/browser/safeMode.js (content/safeMode.js)
* content/browser/safeMode.xul (content/safeMode.xul)
* content/browser/sanitize.js (content/sanitize.js)
* content/browser/sanitize.xul (content/sanitize.xul)
-* content/browser/search.xml (content/search.xml)
-* content/browser/searchDialog.js (content/searchDialog.js)
-* content/browser/searchDialog.xul (content/searchDialog.xul)
-* content/browser/searchDialog.css (content/searchDialog.css)
- content/browser/searchbarBindings.css (content/searchbarBindings.css)
* content/browser/utilityOverlay.js (content/utilityOverlay.js)
* content/browser/web-panels.js (content/web-panels.js)
* content/browser/web-panels.xul (content/web-panels.xul)
* content/browser/baseMenuOverlay.xul (content/baseMenuOverlay.xul)
# XXX: We should exclude this one as well (bug 71895)
* content/browser/hiddenWindow.xul (content/hiddenWindow.xul)
#ifdef XP_MACOSX
* content/browser/macBrowserOverlay.xul (content/macBrowserOverlay.xul)
Index: browser/base/content/browser-context.inc
===================================================================
RCS file: /cvsroot/mozilla/browser/base/content/browser-context.inc,v
retrieving revision 1.18
diff -u -p -8 -r1.18 browser-context.inc
--- browser/base/content/browser-context.inc 9 Mar 2006 02:08:41 -0000 1.18
+++ browser/base/content/browser-context.inc 17 Mar 2006 07:08:15 -0000
@@ -193,17 +193,17 @@
command="cmd_selectAll"/>
+ oncommand="BrowserSearch.loadSearch(getBrowserSelection(), true);"/>
#endif
#ifndef MOZ_PLACES
-
+
#ifdef MOZ_PLACES
#include ../../components/places/content/commands.inc
Index: browser/base/content/browser.css
===================================================================
RCS file: /cvsroot/mozilla/browser/base/content/browser.css,v
retrieving revision 1.15
diff -u -p -8 -r1.15 browser.css
--- browser/base/content/browser.css 9 Mar 2006 02:08:41 -0000 1.15
+++ browser/base/content/browser.css 17 Mar 2006 07:08:17 -0000
@@ -1,10 +1,10 @@
searchbar {
- -moz-binding: url("chrome://browser/content/search.xml#searchbar");
+ -moz-binding: url("chrome://browser/content/search/search.xml#searchbar");
}
/* ::::: print preview toolbar ::::: */
toolbar[printpreview="true"] {
-moz-binding: url("chrome://global/content/printPreviewBindings.xml#printpreviewtoolbar");
}
Index: browser/base/content/browser.js
===================================================================
RCS file: /cvsroot/mozilla/browser/base/content/browser.js,v
retrieving revision 1.589
diff -u -p -8 -r1.589 browser.js
--- browser/base/content/browser.js 17 Mar 2006 02:01:01 -0000 1.589
+++ browser/base/content/browser.js 17 Mar 2006 07:08:21 -0000
@@ -1801,37 +1801,16 @@ function BrowserLoadURL(aTriggeringEvent
aTriggeringEvent.preventCapture();
aTriggeringEvent.stopPropagation();
}
else
loadURI(url, null, aPostData);
content.focus();
}
-function delayedSearchLoadURL(aURL, aInNewTab) {
- setTimeout(SearchLoadURL, 0, aURL, aInNewTab);
-}
-
-function SearchLoadURL(aURL, aInNewTab)
-{
- if (!aURL)
- return;
-
- if (gBrowser.localName == "tabbrowser" && aInNewTab) {
- content.focus();
- // Modal action, remember last viewed tab
- gBrowser.loadOneTab(aURL, null, null, null, false);
- if (gURLBar)
- gURLBar.value = aURL;
- }
- else
- loadURI(aURL, null, null);
- content.focus();
-}
-
function getShortcutOrURI(aURL, aPostDataRef)
{
// rjc: added support for URL shortcuts (3/30/1999)
try {
var shortcutURL = null;
#ifdef MOZ_PLACES
var bookmarkService = Components.classes["@mozilla.org/browser/nav-bookmarks-service;1"]
.getService(nsCI.nsINavBookmarksService);
@@ -2783,117 +2762,93 @@ var DownloadsButtonDNDObserver = {
{
var flavourSet = new FlavourSet();
flavourSet.appendFlavour("text/x-moz-url");
flavourSet.appendFlavour("text/unicode");
return flavourSet;
}
}
-function WebSearch()
-{
+const BrowserSearch = {
+ /**
+ * Gives focus to the search bar, if it is present on the toolbar, or loads
+ * the default engine's search form otherwise. For Mac, opens a new window
+ * or focuses an existing window, if necessary.
+ */
+ webSearch: function BrowserSearch_webSearch() {
#ifdef XP_MACOSX
- if (window.location.href != getBrowserURL()) {
- var win = getTopWin();
- if (win) {
- // If there's an open browser window, it should handle this command
- win.focus()
- win.WebSearch();
- }
- else {
- // If there are no open browser windows, open a new one
- win = window.openDialog("chrome://browser/content/", "_blank",
- "chrome,all,dialog=no", "about:blank");
- win.addEventListener("load", WebSearchCallback, false);
+ if (window.location.href != getBrowserURL()) {
+ var win = getTopWin();
+ if (win) {
+ // If there's an open browser window, it should handle this command
+ win.focus()
+ win.BrowserSearch.webSearch();
+ } else {
+ // If there are no open browser windows, open a new one
+ win = window.openDialog("chrome://browser/content/", "_blank",
+ "chrome,all,dialog=no", "about:blank");
+ win.addEventListener("load", BrowserSearch.WebSearch, false);
+ }
+ return;
}
- return;
- }
#endif
- var searchBar = document.getElementById("searchbar");
- if (searchBar && !searchBar.parentNode.parentNode.collapsed &&
- !(window.getComputedStyle(searchBar.parentNode, null).display == "none")) {
- searchBar.select();
- searchBar.focus();
- } else {
- openDialog("chrome://browser/content/searchDialog.xul", "",
- "chrome,dialog,resizable,modal");
- }
-}
-
-function WebSearchCallback() {
- // make sure the DOM is ready
- setTimeout(function() { this.WebSearch(); }, 0);
-}
-
-function OpenSearch(tabName, searchStr, newTabFlag)
-{
- //This function needs to be split up someday.
- //XXXnoririty I don't want any prefs switching open by tabs to window
- //XXXpch: this routine needs to be cleaned up.
-
- var defaultSearchURL = null;
- var navigatorRegionBundle = document.getElementById("bundle_browser_region");
- var fallbackDefaultSearchURL = navigatorRegionBundle.getString("fallbackDefaultSearchURL");
-
- //Check to see if search string contains "://" or "ftp." or white space.
- //If it does treat as url and match for pattern
-
- var urlmatch= /(:\/\/|^ftp\.)[^ \S]+$/
- var forceAsURL = urlmatch.test(searchStr);
-
- try {
- defaultSearchURL = gPrefService.getComplexValue("browser.search.defaulturl",
- Components.interfaces.nsIPrefLocalizedString).data;
- } catch (ex) {
- }
-
- // Fallback to a default url (one that we can get sidebar search results for)
- if (!defaultSearchURL)
- defaultSearchURL = fallbackDefaultSearchURL;
-
- if (!searchStr) {
- BrowserSearchInternet();
- } else {
-
- //Check to see if location bar field is a url
- //If it is a url go to URL. A Url is "://" or "." as commented above
- //Otherwise search on entry
- if (forceAsURL) {
- BrowserLoadURL(null, null)
+ var searchBar = this.getSearchBar();
+ if (searchBar) {
+ searchBar.select();
+ searchBar.focus();
} else {
- if (searchStr) {
- var escapedSearchStr = encodeURIComponent(searchStr);
- defaultSearchURL += escapedSearchStr;
- var searchDS = Components.classes["@mozilla.org/rdf/datasource;1?name=internetsearch"]
- .getService(Components.interfaces.nsIInternetSearchService);
-
- searchDS.RememberLastSearchText(escapedSearchStr);
- try {
- var searchEngineURI = gPrefService.getCharPref("browser.search.defaultengine");
- if (searchEngineURI) {
- var searchURL = getSearchUrl("actionButton");
- if (searchURL) {
- defaultSearchURL = searchURL + escapedSearchStr;
- } else {
- searchURL = searchDS.GetInternetSearchURL(searchEngineURI, escapedSearchStr, 0, 0, {value:0});
- if (searchURL)
- defaultSearchURL = searchURL;
- }
- }
- } catch (ex) {
- }
-
- if (!newTabFlag) {
- loadURI(defaultSearchURL, null, null);
- }
- else {
- getBrowser().loadOneTab(defaultSearchURL);
- }
- }
+ var ss = Cc["@mozilla.org/browser/search-service;1"].
+ getService(Ci.nsIBrowserSearchService);
+ var searchForm = ss.defaultEngine.searchForm;
+ loadURI(searchForm, null, null);
}
+ },
+
+ /**
+ * Loads a search results page, given a set of search terms. Uses the current
+ * engine if the search bar is visible, or the default engine otherwise.
+ *
+ * @param searchText
+ * The search terms to use for the search.
+ *
+ * @param useNewTab
+ * Boolean indicating whether or not the search should load in a new
+ * tab.
+ */
+ loadSearch: function BrowserSearch_search(searchText, useNewTab) {
+ var ss = Cc["@mozilla.org/browser/search-service;1"].
+ getService(Ci.nsIBrowserSearchService);
+ var engine;
+
+ // If the search bar is visible, use the current engine, otherwise, fall back
+ // to the default engine.
+ if (this.getSearchBar())
+ engine = ss.currentEngine;
+ else
+ engine = ss.defaultEngine;
+
+ var submission = engine.getSubmission(searchText);
+
+ if (useNewTab) {
+ getBrowser().loadOneTab(submission.uri.spec, null, null,
+ submission.postData, false);
+ } else
+ loadURI(submission.uri.spec, null, submission.postData);
+ },
+
+ /**
+ * Returns the search bar element if it is present in the toolbar and not
+ * hidden, null otherwise.
+ */
+ getSearchBar: function BrowserSearch_getSearchBar() {
+ var searchBar = document.getElementById("searchbar");
+ if (searchBar && !searchBar.parentNode.parentNode.collapsed &&
+ !(window.getComputedStyle(searchBar.parentNode, null).display == "none"))
+ return searchBar;
+ return null;
}
}
function FillHistoryMenu(aParent, aMenu, aInsertBefore)
{
// Remove old entries if any
deleteHistoryItems(aParent);
@@ -4898,68 +4853,61 @@ nsContextMenu.prototype = {
text = this.linkURL;
}
}
}
return text;
},
- // Get selected object and convert it to a string to get
- // selected text. Only display the first 15 chars.
+ // Get selected text. Only display the first 15 chars.
isTextSelection : function() {
- var result = false;
- var selection = this.searchSelected(16);
+ // Get 16 characters, so that we can trim the selection if it's greater
+ // than 15 chars
+ var selectedText = getBrowserSelection(16);
- var searchSelectText;
- if (selection) {
- searchSelectText = selection.toString();
- if (searchSelectText.length > 15)
- searchSelectText = searchSelectText.substr(0,15) + "...";
- result = true;
-
- // format "Search for " string to show in menu
- searchSelectText = gNavigatorBundle.getFormattedString("searchText", [searchSelectText]);
- this.setItemAttr("context-searchselect", "label", searchSelectText);
- }
- return result;
+ if (!selectedText)
+ return false;
+
+ if (selectedText.length > 15)
+ selectedText = selectedText.substr(0,15) + "...";
+
+ // Use the current engine if the search bar is visible, the default
+ // engine otherwise.
+ var engineName = "";
+ var ss = Cc["@mozilla.org/browser/search-service;1"].
+ getService(Ci.nsIBrowserSearchService);
+ if (BrowserSearch.getSearchBar())
+ engineName = ss.currentEngine.name;
+ else
+ engineName = ss.defaultEngine.name;
+
+ // format "Search for " string to show in menu
+ var menuLabel = gNavigatorBundle.getFormattedString("contextMenuSearchText",
+ [engineName,
+ selectedText]);
+ this.setItemAttr("context-searchselect", "label", menuLabel);
+
+ return true;
},
// Returns true if anything is selected.
isContentSelection : function() {
return !document.commandDispatcher.focusedWindow.getSelection().isCollapsed;
},
- searchSelected : function( charlen ) {
- var focusedWindow = document.commandDispatcher.focusedWindow;
- var searchStr = focusedWindow.getSelection();
- searchStr = searchStr.toString();
- // searching for more than 150 chars makes no sense
- if (!charlen)
- charlen = 150;
- if (charlen < searchStr.length) {
- // only use the first charlen important chars. see bug 221361
- var pattern = new RegExp("^(?:\\s*.){0," + charlen + "}");
- pattern.test(searchStr);
- searchStr = RegExp.lastMatch;
- }
- searchStr = searchStr.replace(/^\s+/, "");
- searchStr = searchStr.replace(/\s+$/, "");
- searchStr = searchStr.replace(/\s+/g, " ");
- return searchStr;
- },
-
toString : function () {
return "contextMenu.target = " + this.target + "\n" +
"contextMenu.onImage = " + this.onImage + "\n" +
"contextMenu.onLink = " + this.onLink + "\n" +
"contextMenu.link = " + this.link + "\n" +
"contextMenu.inFrame = " + this.inFrame + "\n" +
"contextMenu.hasBGImage = " + this.hasBGImage + "\n";
},
+
isTargetATextBox : function ( node )
{
if (node instanceof HTMLInputElement)
return (node.type == "text" || node.type == "password")
return (node instanceof HTMLTextAreaElement);
},
isTargetAKeywordField : function ( node )
@@ -4996,16 +4944,51 @@ nsContextMenu.prototype = {
return true;
sibling = sibling.previousSibling;
}
}
return false;
}
}
+/**
+ * Gets the selected text in the active browser. Leading and trailing
+ * whitespace is removed, and consecutive whitespace is replaced by a single
+ * space. A maximum of 150 characters will be returned, regardless of the value
+ * of aCharLen.
+ *
+ * @param aCharLen
+ * The maximum number of characters to return.
+ */
+function getBrowserSelection(aCharLen) {
+ // selections of more than 150 characters aren't useful
+ const kMaxSelectionLen = 150;
+ const charLen = Math.min(aCharLen || kMaxSelectionLen, kMaxSelectionLen);
+
+ var focusedWindow = document.commandDispatcher.focusedWindow;
+ var selection = focusedWindow.getSelection().toString();
+
+ if (selection) {
+ if (selection.length > charLen) {
+ // only use the first charLen important chars. see bug 221361
+ var pattern = new RegExp("^(?:\\s*.){0," + charLen + "}");
+ pattern.test(selection);
+ selection = RegExp.lastMatch;
+ }
+
+ selection = selection.replace(/^\s+/, "")
+ .replace(/\s+$/, "")
+ .replace(/\s+/g, " ");
+
+ if (selection.length > charLen)
+ selection = selection.substr(0, charLen);
+ }
+ return selection;
+}
+
var gWebPanelURI;
function openWebPanel(aTitle, aURI)
{
// Ensure that the web panels sidebar is open.
toggleSidebar('viewWebPanelsSidebar', true);
// Set the title of the panel.
document.getElementById("sidebar-title").value = aTitle;
@@ -6552,8 +6535,9 @@ var BookmarksEventHandler = {
event.target.lastChild.showPopup(event.target.lastChild);
}
}
};
#include ../../../toolkit/content/debug.js
#endif
+
Index: browser/base/content/browser.xul
===================================================================
RCS file: /cvsroot/mozilla/browser/base/content/browser.xul,v
retrieving revision 1.289
diff -u -p -8 -r1.289 browser.xul
--- browser/base/content/browser.xul 17 Mar 2006 02:01:04 -0000 1.289
+++ browser/base/content/browser.xul 17 Mar 2006 07:08:21 -0000
@@ -296,17 +296,17 @@
#else
-
-# -*- Mode: HTML -*-
-# ***** BEGIN LICENSE BLOCK *****
-# Version: MPL 1.1/GPL 2.0/LGPL 2.1
-#
-# The contents of this file are subject to the Mozilla Public License Version
-# 1.1 (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-# http://www.mozilla.org/MPL/
-#
-# Software distributed under the License is distributed on an "AS IS" basis,
-# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
-# for the specific language governing rights and limitations under the
-# License.
-#
-# The Original Code is mozilla.org browser.
-#
-# The Initial Developer of the Original Code is
-# Joe Hewitt.
-# Portions created by the Initial Developer are Copyright (C) 2003
-# the Initial Developer. All Rights Reserved.
-#
-# Contributor(s):
-# Pierre Chanial V 2.0 (p_ch@verizon.net)
-# Gavin Sharp (gavin@gavinsharp.com)
-#
-# Alternatively, the contents of this file may be used under the terms of
-# either the GNU General Public License Version 2 or later (the "GPL"), or
-# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
-# in which case the provisions of the GPL or the LGPL are applicable instead
-# of those above. If you wish to allow use of your version of this file only
-# under the terms of either the GPL or the LGPL, and not to allow others to
-# use your version of this file under the terms of the MPL, indicate your
-# decision by deleting the provisions above and replace them with the notice
-# and other provisions required by the GPL or the LGPL. If you do not delete
-# the provisions above, a recipient may use your version of this file under
-# the terms of any one of the MPL, the GPL or the LGPL.
-#
-# ***** END LICENSE BLOCK *****
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- document.getAnonymousNodes(this)[0]
- document.getAnonymousNodes(this)[1]
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- var textBox = document.getAnonymousElementByAttribute(this,
- "anonid", "textbox-input-box");
- return document.getAnonymousElementByAttribute(textBox,
- "anonid", "input-box-contextmenu");
-
-
-
-
-
-
-
-
-
-
-
-
- Components.interfaces.nsIPrefLocalizedString;
-
- this.parentNode.mStringBundle
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- // overload |onTextEntered| in autocomplete.xml
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-#ifndef XP_MACOSX
-
-#endif
-
-
-
-
-
-
- nsDragAndDrop.drop(event, this.searchbarDNDObserver);
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Index: browser/base/content/searchDialog.css
===================================================================
RCS file: browser/base/content/searchDialog.css
diff -N browser/base/content/searchDialog.css
--- browser/base/content/searchDialog.css 5 Sep 2005 22:30:08 -0000 1.2
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,53 +0,0 @@
-/* ***** BEGIN LICENSE BLOCK *****
-%if 0
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is Mozilla Search Dialog.
- *
- * The Initial Developer of the Original Code is
- * Gavin Sharp .
- * Portions created by the Initial Developer are Copyright (C) 2005
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
-%endif
- * ***** END LICENSE BLOCK ***** */
-
-#searchEngineList {
- min-height: 24px;
-}
-
-.engine-icon > .menulist-label-box > .menulist-icon,
-.engine-icon > .menu-iconic-left > .menu-iconic-icon {
- width: 16px;
- height: 16px;
- min-height: 16px;
-}
-
-.engine-icon > .menu-iconic-left {
- display: -moz-box;
- min-height: 16px;
-}
Index: browser/base/content/searchDialog.js
===================================================================
RCS file: browser/base/content/searchDialog.js
diff -N browser/base/content/searchDialog.js
--- browser/base/content/searchDialog.js 13 Dec 2005 13:25:30 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,211 +0,0 @@
-#if 0
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is Mozilla Search Dialog.
- *
- * The Initial Developer of the Original Code is
- * Gavin Sharp .
- * Portions created by the Initial Developer are Copyright (C) 2005
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- * Pierre Chanial
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the LGPL or the GPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-#endif
-
-var gDialog = {};
-var gSelectedEngineIndex;
-
-const kTabPref = "browser.tabs.opentabfor.searchdialog";
-const kEnginePref = "browser.search.selectedEngineInDialog";
-const kDefEnginePref = "browser.search.defaultenginename";
-const nsIPLS = Components.interfaces.nsIPrefLocalizedString;
-const kXUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
-
-function onLoad() {
- setTimeout(onAfterLoad, 0);
-}
-
-function onAfterLoad() {
-
- gDialog.list = document.getElementById("searchEngineList");
- gDialog.list.addEventListener("ValueChange", onEnginesListValueChange, false);
- gDialog.input = document.getElementById("searchInput");
- gDialog.newtab = document.getElementById("searchInNewTab");
- gDialog.searchbundle = document.getElementById("searchbarBundle");
- gDialog.browserbundle = document.getElementById("browserBundle");
-
- var el = document.getAnonymousElementByAttribute(gDialog.input, "anonid",
- "textbox-input-box");
- gDialog.contextmenu = document.getAnonymousElementByAttribute(el,
- "anonid", "input-box-contextmenu");
-
- var pref = Components.classes["@mozilla.org/preferences-service;1"]
- .getService(Components.interfaces.nsIPrefBranch2);
-
- var selectedEngine;
- var tabChecked = false;
- try {
- selectedEngine = pref.getComplexValue(kEnginePref, nsIPLS).data;
- } catch (ex) {
- selectedEngine = pref.getComplexValue(kDefEnginePref, nsIPLS).data;
- }
- try {
- tabChecked = pref.getBoolPref(kTabPref);
- } catch (ex) { }
-
- gDialog.newtab.setAttribute("checked", tabChecked);
-
- for (var i=0; i < gDialog.list.menupopup.childNodes.length; i++) {
- var label = gDialog.list.menupopup.childNodes[i].getAttribute("label");
- if (label == selectedEngine)
- gDialog.list.selectedIndex = i;
- }
-
- // Make sure we have a selected item
- if (gDialog.list.selectedIndex == -1)
- gDialog.list.selectedIndex = 0;
-
- gSelectedEngineIndex = gDialog.list.selectedIndex;
-
- // Add "Clear Search History" item to the text box context menu
- var sep = document.createElementNS(kXUL_NS, "menuseparator");
- gDialog.contextmenu.appendChild(sep);
-
- var element = document.createElementNS(kXUL_NS, "menuitem");
-
- var label = gDialog.searchbundle.getString("cmd_clearHistory");
- var accesskey = gDialog.searchbundle.getString("cmd_clearHistory_accesskey");
- element.setAttribute("label", label);
- element.setAttribute("accesskey", accesskey);
- element.setAttribute("cmd", "cmd_clearhistory");
-
- gDialog.contextmenu.appendChild(element);
- gDialog.input.controllers.appendController(clearHistoryController);
-}
-
-function onEnginesListValueChange() {
- if (gDialog.list.value == "addengines") {
- var url = gDialog.browserbundle.getString("searchEnginesURL");
- window.opener.openNewWindowWith(url, null, false);
- gDialog.list.selectedIndex = gSelectedEngineIndex;
- } else {
- gSelectedEngineIndex = gDialog.list.selectedIndex;
- }
-}
-
-function updateAddEnginesItem(aAdd) {
- // Remove the old item if it exists
- var elem = document.getElementById("addenginemenuitem");
- var sep = document.getElementById("addenginesep");
- if (elem)
- gDialog.list.menupopup.removeChild(elem);
- if (sep)
- gDialog.list.menupopup.removeChild(sep);
-
- if (aAdd) {
- // Add "Add Engines" item to the drop down
- var sep = document.createElementNS(kXUL_NS, "menuseparator");
- sep.setAttribute("id", "addenginesep");
- gDialog.list.menupopup.appendChild(sep);
-
- var label = gDialog.searchbundle.getString("cmd_addEngine");
- var newItem = gDialog.list.appendItem(label, "addengines");
- newItem.setAttribute("id", "addenginemenuitem");
- newItem.setAttribute("class", "menuitem-iconic engine-icon");
- }
-}
-
-function onDialogAccept() {
- var searchText = gDialog.input.value;
- var engine = gDialog.list.value;
- var searchURL;
-
- var searchSvc =
- Components.classes["@mozilla.org/rdf/datasource;1?name=internetsearch"]
- .getService(Components.interfaces.nsIInternetSearchService);
-
- // XXX Bug 269994: Use dummy string if there is no user entered string
- searchURL = searchSvc.GetInternetSearchURL(engine,
- searchText ? encodeURIComponent(searchText):"A",
- 0, 0, {value:0});
-
- if (searchText) {
- // Add item to form history
- var frmHistSvc = Components.classes["@mozilla.org/satchel/form-history;1"]
- .getService(Components.interfaces.nsIFormHistory);
- frmHistSvc.addEntry("searchbar-history", searchText);
- } else {
- try {
- // Get the engine's base URL
- searchURL = makeURI(searchURL).host;
- } catch (ex) {}
- }
-
- setPrefs();
- gDialog.input.controllers.removeController(clearHistoryController);
-
- window.opener.delayedSearchLoadURL(searchURL, gDialog.newtab.checked);
-
- // Delay closing slightly to avoid timing bug on Linux.
- window.close();
- return false;
-}
-
-function setPrefs() {
- var pref = Components.classes["@mozilla.org/preferences-service;1"]
- .getService(Components.interfaces.nsIPrefBranch2);
-
- var pls = Components.classes["@mozilla.org/pref-localizedstring;1"]
- .createInstance(nsIPLS);
-
- var name = gDialog.list.selectedItem.getAttribute("label");
- pls.data = name;
-
- pref.setComplexValue(kEnginePref, nsIPLS, pls);
- pref.setBoolPref(kTabPref, gDialog.newtab.checked);
-}
-
-var clearHistoryController = {
- frmHistSvc: Components.classes["@mozilla.org/satchel/form-history;1"]
- .getService(Components.interfaces.nsIFormHistory),
-
- autocompleteSearchParam: "searchbar-history",
-
- supportsCommand: function (aCommand) {
- return aCommand == "cmd_clearhistory";
- },
-
- isCommandEnabled: function (aCommand) {
- return this.frmHistSvc.nameExists(this.autocompleteSearchParam);
- },
-
- doCommand: function (aCommand) {
- this.frmHistSvc.removeEntriesForName(this.autocompleteSearchParam);
- gDialog.input.value = "";
- }
-}
Index: browser/base/content/searchDialog.xul
===================================================================
RCS file: browser/base/content/searchDialog.xul
diff -N browser/base/content/searchDialog.xul
--- browser/base/content/searchDialog.xul 29 Aug 2005 02:10:58 -0000 1.2
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,110 +0,0 @@
-
-
-
-
-
-
-
-
-
-
Index: browser/base/content/searchbarBindings.css
===================================================================
RCS file: browser/base/content/searchbarBindings.css
diff -N browser/base/content/searchbarBindings.css
--- browser/base/content/searchbarBindings.css 30 Nov 2004 08:22:43 -0000 1.2
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,11 +0,0 @@
-@namespace url("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul");
-
-.searchbar-textbox {
- -moz-binding: url("chrome://browser/content/search.xml#searchbar-textbox");
-}
-
-.searchbar-dropmarker {
- -moz-binding: url("chrome://browser/content/search.xml#searchbar-dropmarker");
- -moz-user-focus: none;
-}
-
Index: browser/components/Makefile.in
===================================================================
RCS file: /cvsroot/mozilla/browser/components/Makefile.in,v
retrieving revision 1.44
diff -u -p -8 -r1.44 Makefile.in
--- browser/components/Makefile.in 24 Feb 2006 21:41:15 -0000 1.44
+++ browser/components/Makefile.in 17 Mar 2006 07:08:22 -0000
@@ -54,16 +54,17 @@ EXTRA_PP_COMPONENTS = \
nsBrowserContentHandler.js \
nsBrowserGlue.js \
$(NULL)
DIRS = \
dirprovider \
migration \
preferences \
+ search \
shell \
sidebar \
$(NULL)
ifdef MOZ_PLACES
DIRS += places
else
DIRS += history bookmarks
Index: browser/components/bookmarks/content/bookmarksTree.xml
===================================================================
RCS file: /cvsroot/mozilla/browser/components/bookmarks/content/bookmarksTree.xml,v
retrieving revision 1.70
diff -u -p -8 -r1.70 bookmarksTree.xml
--- browser/components/bookmarks/content/bookmarksTree.xml 10 Oct 2005 02:37:44 -0000 1.70
+++ browser/components/bookmarks/content/bookmarksTree.xml 17 Mar 2006 07:08:24 -0000
@@ -844,17 +844,17 @@
@@ -940,17 +940,17 @@
xmlns:xbl="http://www.mozilla.org/xbl" contextmenu="_child">
@@ -980,17 +980,17 @@
Index: browser/components/search/Makefile.in
===================================================================
RCS file: browser/components/search/Makefile.in
diff -N browser/components/search/Makefile.in
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ browser/components/search/Makefile.in 17 Mar 2006 07:08:43 -0000
@@ -0,0 +1,53 @@
+# ***** BEGIN LICENSE BLOCK *****
+# Version: MPL 1.1/GPL 2.0/LGPL 2.1
+#
+# The contents of this file are subject to the Mozilla Public License Version
+# 1.1 (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+# http://www.mozilla.org/MPL/
+#
+# Software distributed under the License is distributed on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+# for the specific language governing rights and limitations under the
+# License.
+#
+# The Original Code is the Browser Search Service.
+#
+# The Initial Developer of the Original Code is
+# Google Inc.
+# Portions created by the Initial Developer are Copyright (C) 2005
+# the Initial Developer. All Rights Reserved.
+#
+# Contributor(s):
+# Ben Goodger (Original author)
+# Gavin Sharp
+#
+# Alternatively, the contents of this file may be used under the terms of
+# either the GNU General Public License Version 2 or later (the "GPL"), or
+# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+# in which case the provisions of the GPL or the LGPL are applicable instead
+# of those above. If you wish to allow use of your version of this file only
+# under the terms of either the GPL or the LGPL, and not to allow others to
+# use your version of this file under the terms of the MPL, indicate your
+# decision by deleting the provisions above and replace them with the notice
+# and other provisions required by the GPL or the LGPL. If you do not delete
+# the provisions above, a recipient may use your version of this file under
+# the terms of any one of the MPL, the GPL or the LGPL.
+#
+# ***** END LICENSE BLOCK ***** */
+
+DEPTH = ../../..
+topsrcdir = @top_srcdir@
+srcdir = @srcdir@
+VPATH = @srcdir@
+
+include $(DEPTH)/config/autoconf.mk
+
+MODULE = browsersearch
+XPIDL_MODULE = browsersearch
+
+XPIDLSRCS = nsIBrowserSearchService.idl
+
+EXTRA_PP_COMPONENTS = nsSearchService.js
+
+include $(topsrcdir)/config/rules.mk
Index: browser/components/search/jar.mn
===================================================================
RCS file: browser/components/search/jar.mn
diff -N browser/components/search/jar.mn
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ browser/components/search/jar.mn 17 Mar 2006 07:08:43 -0000
@@ -0,0 +1,3 @@
+browser.jar:
+* content/browser/search/search.xml (content/search.xml)
+ content/browser/search/searchbarBindings.css (content/searchbarBindings.css)
Index: browser/components/search/nsIBrowserSearchService.idl
===================================================================
RCS file: browser/components/search/nsIBrowserSearchService.idl
diff -N browser/components/search/nsIBrowserSearchService.idl
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ browser/components/search/nsIBrowserSearchService.idl 17 Mar 2006 07:08:43 -0000
@@ -0,0 +1,288 @@
+# ***** BEGIN LICENSE BLOCK *****
+# Version: MPL 1.1/GPL 2.0/LGPL 2.1
+#
+# The contents of this file are subject to the Mozilla Public License Version
+# 1.1 (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+# http://www.mozilla.org/MPL/
+#
+# Software distributed under the License is distributed on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+# for the specific language governing rights and limitations under the
+# License.
+#
+# The Original Code is the Browser Search Service.
+#
+# The Initial Developer of the Original Code is
+# Google Inc.
+# Portions created by the Initial Developer are Copyright (C) 2005
+# the Initial Developer. All Rights Reserved.
+#
+# Contributor(s):
+# Ben Goodger (Original author)
+# Gavin Sharp
+#
+# Alternatively, the contents of this file may be used under the terms of
+# either the GNU General Public License Version 2 or later (the "GPL"), or
+# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+# in which case the provisions of the GPL or the LGPL are applicable instead
+# of those above. If you wish to allow use of your version of this file only
+# under the terms of either the GPL or the LGPL, and not to allow others to
+# use your version of this file under the terms of the MPL, indicate your
+# decision by deleting the provisions above and replace them with the notice
+# and other provisions required by the GPL or the LGPL. If you do not delete
+# the provisions above, a recipient may use your version of this file under
+# the terms of any one of the MPL, the GPL or the LGPL.
+#
+# ***** END LICENSE BLOCK *****
+
+#include "nsISupports.idl"
+
+interface nsIURI;
+interface nsIInputStream;
+
+[scriptable, uuid(1163b8bf-3446-4a36-a4df-9e870125b076)]
+interface nsISearchSubmission : nsISupports
+{
+ /**
+ * The POST data associated with a search submission, wrapped in a MIME
+ * input stream. May be null.
+ */
+ readonly attribute nsIInputStream postData;
+
+ /**
+ * The URI to submit a search to.
+ */
+ readonly attribute nsIURI uri;
+};
+
+[scriptable, uuid(b64edb5b-4d05-44df-b9bf-2098d9069f88)]
+interface nsISearchEngine : nsISupports
+{
+ /**
+ * Gets a nsISearchSubmission object that contains information about what to
+ * send to the search engine, including the URI and postData, if applicable.
+ *
+ * @param data
+ * Data to add to the submission object.
+ * i.e. the search terms.
+ *
+ * @returns A nsISearchSubmission object that contains information about what
+ * to send to the search engine.
+ */
+ nsISearchSubmission getSubmission(in AString data);
+
+ /**
+ * Adds a parameter to the search engine's submission data. This should only
+ * be called on engine's created via addEngineWithDetails.
+ *
+ * @param name
+ * The parameter's name. Must not be null.
+ *
+ * @param value
+ * The value to pass. If value is "{searchTerms}", it will be
+ * substituted with the user-entered data when retrieving the
+ * submission. Must not be null.
+ *
+ * @throws NS_ERROR_FAILURE if the search engine is read-only.
+ * @throws NS_ERROR_INVALID_ARG if name or value are null.
+ */
+ void addParam(in AString name, in AString value);
+
+ /**
+ * Supported search engine types.
+ */
+ const unsigned long TYPE_MOZSEARCH = 1;
+ const unsigned long TYPE_SHERLOCK = 2;
+ const unsigned long TYPE_OPENSEARCH = 3;
+
+ /**
+ * Supported search engine data types.
+ */
+ const unsigned long DATA_XML = 1;
+ const unsigned long DATA_TEXT = 2;
+
+ /**
+ * The shortcut alias of the engine. This is a unique identifier.
+ */
+ attribute AString alias;
+
+ /**
+ * Whether the engine should be hidden from the user.
+ */
+ attribute boolean hidden;
+
+ /**
+ * A nsIURI corresponding to the engine's icon, stored locally. May be null.
+ */
+ readonly attribute nsIURI iconURI;
+
+ /**
+ * The display name of the search engine. This is a unique identifier.
+ */
+ readonly attribute AString name;
+
+ /**
+ * The search engine type.
+ */
+ readonly attribute long type;
+
+ /**
+ * A URL string pointing to the engine's search form.
+ */
+ readonly attribute AString searchForm;
+
+};
+
+[scriptable, uuid(eaa8c60f-a0d7-4afe-b629-ab5ac9434298)]
+interface nsIBrowserSearchService : nsISupports
+{
+ /**
+ * Adds a new search engine from the file at the supplied URI.
+ *
+ * @param engineURL
+ * The URL to the search engine's description file.
+ *
+ * @param type
+ * An integer representing the plugin file format. Must be one
+ * of the supported search engine data types defined above.
+ *
+ * @param iconURL the URL to an icon file to be used as the search engine's
+ * icon.
+ *
+ * @throws NS_ERROR_FAILURE if the type is invalid, or if the description
+ * file cannot be successfully loaded.
+ */
+ void addEngine(in AString engineURL, in long type, in AString iconURL);
+
+ /**
+ * Adds a new search engine.
+ *
+ * @param name
+ * The search engine's name. Must be unique. Must not be null.
+ *
+ * @param iconURL
+ * Optional: A URL string pointing to the icon to be used to represent
+ * the engine.
+ *
+ * @param alias
+ * Optional: A unique shortcut that can be used to retrieve the
+ * search engine.
+ *
+ * @param description
+ * Optional: a description of the search engine.
+ *
+ * @param method
+ * The HTTP request method used when submitting a search query.
+ * Must be a case insensitive value of either "get" or "post".
+ *
+ * @param url
+ * The URL to which search queries should be sent.
+ * Must not be null.
+ */
+ void addEngineWithDetails(in AString name,
+ in AString iconURL,
+ in AString alias,
+ in AString description,
+ in AString method,
+ in AString url);
+
+ /**
+ * Returns an engine with the specified alias.
+ *
+ * @param alias
+ * The search engine's alias.
+ * @returns The corresponding nsISearchEngine object, or null if it doesn't
+ * exist.
+ */
+ nsISearchEngine getEngineByAlias(in AString alias);
+
+ /**
+ * Returns an engine with the specified name.
+ *
+ * @param aEngineName
+ * The name of the engine.
+ * @returns The corresponding nsISearchEngine object, or null if it doesn't
+ * exist.
+ */
+ nsISearchEngine getEngineByName(in AString aEngineName);
+
+ /**
+ * Returns an array of all installed search engines.
+ *
+ * @returns an array of nsISearchEngine objects.
+ */
+ void getEngines(
+ out unsigned long engineCount,
+ [retval, array, size_is(engineCount)] out nsISearchEngine engines);
+
+ /**
+ * Returns an array of all installed search engines whose hidden attribute is
+ * false.
+ *
+ * @returns an array of nsISearchEngine objects.
+ */
+ void getVisibleEngines(
+ out unsigned long engineCount,
+ [retval, array, size_is(engineCount)] out nsISearchEngine engines);
+
+ /**
+ * Removes the search engine. If the search engine is installed in a global
+ * location, this will just hide the engine. If the engine is in the user's
+ * profile directory, it will be removed from disk.
+ *
+ * @param engine
+ * The engine to remove.
+ */
+ void removeEngine(in nsISearchEngine engine);
+
+ /**
+ * The default search engine.
+ */
+ readonly attribute nsISearchEngine defaultEngine;
+
+ /**
+ * The currently active search engine.
+ */
+ attribute nsISearchEngine currentEngine;
+
+};
+
+%{ C++
+/**
+ * The observer topic to listen to for actions performed on installed
+ * search engines.
+ */
+#define SEARCH_ENGINE_TOPIC "browser-search-engine-modified"
+
+/**
+ * Sent when an engine is removed from the data store.
+ */
+#define SEARCH_ENGINE_REMOVED "engine-removed"
+
+/**
+ * Sent when an engine is changed. This includes when the engine's "hidden"
+ * property is changed.
+ */
+#define SEARCH_ENGINE_CHANGED "engine-changed"
+
+/**
+ * Sent when an engine is added to the list of available engines.
+ */
+#define SEARCH_ENGINE_ADDED "engine-added"
+
+/**
+ * Sent when a search engine being installed from a remote plugin description
+ * file is completely loaded. This is used internally by the search service as
+ * an indication of when the engine can be added to the internal store, and
+ * therefore should not be used to detect engine availability. It is always
+ * followed by an "added" notification.
+ */
+#define SEARCH_ENGINE_LOADED "engine-loaded"
+
+/**
+ * Sent when the "current" engine is changed.
+ */
+#define SEARCH_ENGINE_CURRENT "engine-current";
+
+%}
Index: browser/components/search/nsSearchService.js
===================================================================
RCS file: browser/components/search/nsSearchService.js
diff -N browser/components/search/nsSearchService.js
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ browser/components/search/nsSearchService.js 17 Mar 2006 07:08:45 -0000
@@ -0,0 +1,2071 @@
+# ***** BEGIN LICENSE BLOCK *****
+# Version: MPL 1.1/GPL 2.0/LGPL 2.1
+#
+# The contents of this file are subject to the Mozilla Public License Version
+# 1.1 (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+# http://www.mozilla.org/MPL/
+#
+# Software distributed under the License is distributed on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+# for the specific language governing rights and limitations under the
+# License.
+#
+# The Original Code is the Browser Search Service.
+#
+# The Initial Developer of the Original Code is
+# Google Inc.
+# Portions created by the Initial Developer are Copyright (C) 2005
+# the Initial Developer. All Rights Reserved.
+#
+# Contributor(s):
+# Ben Goodger (Original author)
+# Gavin Sharp
+#
+# Alternatively, the contents of this file may be used under the terms of
+# either the GNU General Public License Version 2 or later (the "GPL"), or
+# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+# in which case the provisions of the GPL or the LGPL are applicable instead
+# of those above. If you wish to allow use of your version of this file only
+# under the terms of either the GPL or the LGPL, and not to allow others to
+# use your version of this file under the terms of the MPL, indicate your
+# decision by deleting the provisions above and replace them with the notice
+# and other provisions required by the GPL or the LGPL. If you do not delete
+# the provisions above, a recipient may use your version of this file under
+# the terms of any one of the MPL, the GPL or the LGPL.
+#
+# ***** END LICENSE BLOCK ***** */
+
+const Ci = Components.interfaces;
+const Cc = Components.classes;
+const Cr = Components.results;
+
+const PERMS_FILE = 0644;
+const PERMS_DIRECTORY = 0755;
+
+const MODE_RDONLY = 0x01;
+const MODE_WRONLY = 0x02;
+const MODE_CREATE = 0x08;
+const MODE_APPEND = 0x10;
+const MODE_TRUNCATE = 0x20;
+
+const NS_APP_SEARCH_DIR_LIST = "SrchPluginsDL";
+const NS_APP_USER_SEARCH_DIR = "UsrSrchPlugns";
+
+// See documentation in nsIBrowserSearchService.idl.
+const SEARCH_ENGINE_TOPIC = "browser-search-engine-modified";
+
+const SEARCH_ENGINE_REMOVED = "engine-removed";
+const SEARCH_ENGINE_ADDED = "engine-added";
+const SEARCH_ENGINE_CHANGED = "engine-changed";
+const SEARCH_ENGINE_LOADED = "engine-loaded";
+const SEARCH_ENGINE_CURRENT = "engine-current";
+
+const XPCOM_SHUTDOWN_TOPIC = "xpcom-shutdown";
+
+// File extensions for search plugin description files
+const XML_FILE_EXT = "xml";
+const SHERLOCK_FILE_EXT = "src";
+
+const ICON_DATAURL_PREFIX = "data:image/x-icon;base64,";
+
+// Supported extensions for Sherlock plugin icons
+const SHERLOCK_ICON_EXTENSIONS = [".gif", ".jpg", ".jpeg", ".png"];
+
+// Set an arbitrary cap on the maximum icon size. Without this, large icons can
+// cause big delays when loading them at startup.
+const MAX_ICON_SIZE = 10000;
+
+// Default charset to use for sending search parameters. This is used to match
+// previous nsInternetSearchService behavior.
+const DEFAULT_QUERY_CHARSET = "ISO-8859-1";
+
+const SEARCH_BUNDLE = "chrome://browser/locale/search.properties";
+const BRAND_BUNDLE = "chrome://branding/locale/brand.properties";
+
+const kOpenSearchNS_10 = "http://a9.com/-/spec/opensearchdescription/1.0/";
+const kOpenSearchNS_11 = "http://a9.com/-/spec/opensearchdescription/1.1/";
+const kOpenSearchLocalName = "OpenSearchDescription";
+
+const kMozSearchNS_10 = "http://www.mozilla.org/2006/browser/search/";
+const kMozSearchLocalName = "SearchPlugin";
+
+// Empty base document used to serialize engines to file.
+const EMPTY_DOC = "\n" +
+ "<" + kMozSearchLocalName +
+ " xmlns=\"" + kMozSearchNS_10 + "\"" +
+ " xmlns:os=\"" + kOpenSearchNS_11 + "\"" +
+ "/>";
+
+const BROWSER_SEARCH_PREF = "browser.search.";
+
+// Unsupported search parameters.
+// XXX We do use inputEncoding - should consider having it available. This
+// would require doing multiple parameter substition, so just having
+// searchTerms is sufficient for now.
+const kIllegalWords = /(\{count\})|(\{startIndex\})|(\{startPage\})|(\{language\})|(\{outputEncoding\})|(\{inputEncoding\})/;
+
+const kValidWords = /\{searchTerms\}/gi;
+const kUserDefined = "{searchTerms}";
+
+// Regular expression matching whitespace-only or commented out lines in a
+// Sherlock file.
+const kUselessLine = /^\s*($|#)/i;
+
+/**
+ * Used to determine whether an "input" line from a Sherlock file is a "user
+ * defined" input. That is, check for the string "user", preceded by either
+ * whitespace or a quote, followed by any of ">", "=", """, "'", whitespace,
+ * a slash, "+", or EOL.
+ */
+const kIsUserInput = /(\s|["'=])user(\s|[>="'\/\\+]|$)/i;
+
+/**
+ * Outputs aText to the JavaScript console as well as to stdout, if the search
+ * logging pref (browser.search.log) is set to true.
+ */
+function LOG(aText) {
+ var prefB = Cc["@mozilla.org/preferences-service;1"].
+ getService(Ci.nsIPrefBranch);
+ var shouldLog = false;
+ try {
+ shouldLog = prefB.getBoolPref(BROWSER_SEARCH_PREF + "log");
+ } catch (ex) {}
+
+ if (shouldLog) {
+ dump("*** Search: " + aText + "\n");
+ var consoleService = Cc["@mozilla.org/consoleservice;1"].
+ getService(Ci.nsIConsoleService);
+ consoleService.logStringMessage(aText);
+ }
+}
+
+//XXX Bug 327349: Copied from controller.js, this belongs in a global place
+function ASSERT(condition, message) {
+ if (!condition) {
+ var caller = arguments.callee.caller;
+ var str = "ASSERT: ";
+ str += message;
+ LOG(str);
+ var assertionText = str + "\n";
+
+ var stackText = "Stack Trace: \n";
+ if (true) {
+ var count = 0;
+ while (caller) {
+ stackText += count++ + ":" + caller.name + "(";
+ for (var i = 0; i < caller.arguments.length; ++i) {
+ var arg = caller.arguments[i];
+ stackText += arg;
+ if (i < caller.arguments.length - 1)
+ stackText += ",";
+ }
+ stackText += ")\n";
+ caller = caller.arguments.callee.caller;
+ }
+ }
+ var ps = Cc["@mozilla.org/embedcomp/prompt-service;1"].
+ getService(Ci.nsIPromptService);
+ ps.alert(null, "Assertion Failed", assertionText + stackText);
+ LOG(assertionText);
+ }
+}
+
+function ERROR(message, resultCode) {
+ ASSERT(false, message);
+ throw resultCode;
+}
+
+/**
+ * Ensures an assertion is met before continuing. Should be used to indicate
+ * fatal errors.
+ * @param assertion
+ * An assertion that must be met
+ * @param message
+ * A message to display if the assertion is not met
+ * @param resultCode
+ * The NS_ERROR_* value to throw if the assertion is not met
+ * @throws resultCode
+ */
+function ENSURE_WARN(assertion, message, resultCode) {
+ ASSERT(assertion, message);
+ if (!assertion)
+ throw resultCode;
+}
+
+/**
+ * Ensures an assertion is met before continuing, but does not warn the user.
+ * Used to handle normal failure conditions.
+ * @param assertion
+ * An assertion that must be met
+ * @param message
+ * A message to display if the assertion is not met
+ * @param resultCode
+ * The NS_ERROR_* value to throw if the assertion is not met
+ * @throws resultCode
+ */
+function ENSURE(assertion, message, resultCode) {
+ if (!assertion) {
+ LOG(message, true);
+ throw resultCode;
+ }
+}
+
+/**
+ * Ensures an argument assertion is met before continuing.
+ * @param assertion
+ * An argument assertion that must be met
+ * @param message
+ * A message to display if the assertion is not met
+ * @throws NS_ERROR_INVALID_ARG for invalid arguments
+ */
+function ENSURE_ARG(assertion, message) {
+ ENSURE(assertion, message, Cr.NS_ERROR_INVALID_ARG);
+}
+
+//XXX Bug 326854: no btoa for components, use our own
+/**
+ * Encodes an array of bytes into a string using the base 64 encoding scheme.
+ * @param aBytes
+ * An array of bytes to encode.
+ */
+function b64(aBytes) {
+ const B64_CHARS =
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
+ var out = "", bits = 0, i, j;
+
+ while (aBytes.length >= 3) {
+ bits = 0;
+ for (i=0; i<3; i++) {
+ bits <<= 8;
+ bits |= aBytes[i];
+ }
+ for (j=18; j>=0; j-=6)
+ out += B64_CHARS[(bits>>j) & 0x3F];
+
+ aBytes.splice(0, 3);
+ }
+
+ switch (aBytes.length) {
+ case 2:
+ out += B64_CHARS[(aBytes[0]>>2) & 0x3F];
+ out += B64_CHARS[((aBytes[0] & 0x03) << 4) | ((aBytes[1] >> 4) & 0x0F)];
+ out += B64_CHARS[((aBytes[1] & 0x0F) << 2)];
+ out += "=";
+ break;
+ case 1:
+ out += B64_CHARS[(aBytes[0]>>2) & 0x3F];
+ out += B64_CHARS[(aBytes[0] & 0x03) << 4];
+ out += "==";
+ break;
+ }
+ return out;
+}
+
+function iconLoadListener(aChannel, aEngine) {
+ this._countRead = 0;
+ this._channel = aChannel;
+ this._bytes = [],
+ this._engine = aEngine.QueryInterface(Ci.nsISearchEngine);
+}
+iconLoadListener.prototype = {
+ _channel: null,
+ _countRead: 0,
+ _engine: null,
+ _stream: null,
+
+ QueryInterface: function SRCH_iconLoad_QI(aIID) {
+ if (aIID.equals(Ci.nsISupports) ||
+ aIID.equals(Ci.nsIRequestObserver) ||
+ aIID.equals(Ci.nsIStreamListener) ||
+ aIID.equals(Ci.nsIChannelEventSink) ||
+ aIID.equals(Ci.nsIInterfaceRequestor) ||
+ // See XXX comment below
+ aIID.equals(Ci.nsIHttpEventSink) ||
+ aIID.equals(Ci.nsIProgressEventSink) ||
+ false)
+ return this;
+
+ throw Cr.NS_ERROR_NO_INTERFACE;
+ },
+
+ // nsIRequestObserver
+ onStartRequest: function SRCH_iconLoadStartR(aRequest, aContext) {
+ LOG("iconLoadListener: Starting icon request.");
+ this._stream = Cc["@mozilla.org/binaryinputstream;1"].
+ createInstance(Ci.nsIBinaryInputStream);
+ },
+
+ onStopRequest: function SRCH_iconLoadStopR(aRequest, aContext, aStatusCode) {
+ LOG("iconLoadListener: Stopping icon request.");
+ var httpChannel = this._channel.QueryInterface(Ci.nsIHttpChannel);
+ if ((httpChannel && httpChannel.requestSucceeded) &&
+ Components.isSuccessCode(aStatusCode) &&
+ this._countRead > 0) {
+
+ if (this._countRead < MAX_ICON_SIZE) {
+ var str = b64(this._bytes);
+ this._engine._iconURI = makeURI(ICON_DATAURL_PREFIX + str);
+
+ // The engine might not have a file yet, if it's being downloaded,
+ // because the request for the engine file itself (_onLoad) may not yet
+ // have occured. In that case, this change will be written to file when
+ // _onLoad is called.
+ if (this._engine._file)
+ this._engine._serializeToFile();
+ notifyAction(this._engine, SEARCH_ENGINE_CHANGED);
+ }
+ }
+ this._channel = null;
+ this._engine = null;
+ },
+
+ // nsIStreamListener
+ onDataAvailable: function SRCH_iconLoadDAvailable(aRequest, aContext,
+ aInputStream, aOffset,
+ aCount) {
+ this._stream.setInputStream(aInputStream);
+
+ // Get a byte array of the data
+ this._bytes = this._bytes.concat(this._stream.readByteArray(aCount));
+ this._countRead += aCount;
+ },
+
+ // nsIChannelEventSink
+ onChannelRedirect: function SRCH_iconLoadCRedirect(aOldChannel, aNewChannel,
+ aFlags) {
+ this._channel = aNewChannel;
+ },
+
+ // nsIInterfaceRequestor
+ getInterface: function SRCH_iconLoad_GI(aIID) {
+ return this.QueryInterface(aIID);
+ },
+
+ // XXX bug 253127
+ // nsIHttpEventSink
+ onRedirect: function (aChannel, aNewChannel) {},
+ // nsIProgressEventSink
+ onProgress: function (aRequest, aContext, aProgress, aProgressMax) {},
+ onStatus: function (aRequest, aContext, aStatus, aStatusArg) {}
+}
+
+
+/**
+ * Used to verify a given DOM node's localName and namespaceURI.
+ * @param aElement
+ * The element to verify.
+ * @param aLocalNameArray
+ * An array of strings to compare against aElement's localName.
+ * @param aNameSpaceArray
+ * An array of strings to compare against aElement's namespaceURI.
+ *
+ * @returns false if aElement is null, or if it's localName or namespaceURI
+ * does not match one of the elements in the aLocalNameArray or
+ * aNameSpaceArray arrays, respectively.
+ * @throws NS_ERROR_INVALID_ARG if aLocalNameArray or aNameSpaceArray are null.
+ */
+function checkNameSpace(aElement, aLocalNameArray, aNameSpaceArray) {
+ ENSURE_ARG(aLocalNameArray && aNameSpaceArray, "missing aLocalNameArray or \
+ aNameSpaceArray for checkNameSpace");
+ return (aElement &&
+ (aLocalNameArray.indexOf(aElement.localName) != -1) &&
+ (aNameSpaceArray.indexOf(aElement.namespaceURI) != -1));
+}
+
+/**
+ * Safely close a nsISafeOutputStream.
+ * @param aFOS
+ * The file output stream to close.
+ */
+function closeSafeOutputStream(aFOS) {
+ if (aFOS instanceof Ci.nsISafeOutputStream) {
+ try {
+ aFOS.finish();
+ return;
+ } catch (e) { }
+ }
+ aFOS.close();
+}
+
+/**
+ * Wrapper function for nsIIOService::newURI.
+ * @param aURLSpec
+ * The URL string from which to create an nsIURI.
+ * @returns an nsIURI object, or null if the creation of the URI failed.
+ */
+function makeURI(aURLSpec) {
+ var ios = Cc["@mozilla.org/network/io-service;1"].
+ getService(Ci.nsIIOService);
+ try {
+ return ios.newURI(aURLSpec, null, null);
+ } catch (ex) { }
+
+ return null;
+}
+
+/**
+ * Gets a directory from the directory service.
+ * @param aKey
+ * The directory service key indicating the directory to get.
+ */
+function getDir(aKey) {
+ ENSURE_ARG(aKey, "getDir requires a directory key!");
+
+ var fileLocator = Cc["@mozilla.org/file/directory_service;1"].
+ getService(Ci.nsIProperties);
+ var dir = fileLocator.get(aKey, Ci.nsIFile);
+ return dir;
+}
+
+// This isn't a full list - this is just copied over from
+// nsInternetSearchService to maintain backwards compat with Firefox 1.0.x
+const kCharsetCodes = [];
+kCharsetCodes[0] = "x-mac-roman";
+kCharsetCodes[6] = "x-mac-greek";
+kCharsetCodes[35] = "x-mac-turkish";
+kCharsetCodes[513] = "ISO-8859-1";
+kCharsetCodes[514] = "ISO-8859-2";
+kCharsetCodes[517] = "ISO-8859-5";
+kCharsetCodes[518] = "ISO-8859-6";
+kCharsetCodes[519] = "ISO-8859-7";
+kCharsetCodes[520] = "ISO-8859-8";
+kCharsetCodes[521] = "ISO-8859-9";
+kCharsetCodes[1049] = "IBM864";
+kCharsetCodes[1280] = "windows-1252";
+kCharsetCodes[1281] = "windows-1250";
+kCharsetCodes[1282] = "windows-1251";
+kCharsetCodes[1283] = "windows-1253";
+kCharsetCodes[1284] = "windows-1254";
+kCharsetCodes[1285] = "windows-1255";
+kCharsetCodes[1286] = "windows-1256";
+kCharsetCodes[1536] = "us-ascii";
+kCharsetCodes[1584] = "GB2312";
+kCharsetCodes[1585] = "x-gbk";
+kCharsetCodes[1600] = "EUC-KR";
+kCharsetCodes[2080] = "ISO-2022-JP";
+kCharsetCodes[2096] = "ISO-2022-CN";
+kCharsetCodes[2112] = "ISO-2022-KR";
+kCharsetCodes[2336] = "EUC-JP";
+kCharsetCodes[2352] = "GB2312";
+kCharsetCodes[2353] = "x-euc-tw";
+kCharsetCodes[2368] = "EUC-KR";
+kCharsetCodes[2561] = "Shift_JIS";
+kCharsetCodes[2562] = "KOI8-R";
+kCharsetCodes[2563] = "Big5";
+kCharsetCodes[2565] = "HZ-GB-2312";
+
+/**
+ * Gets a character set name from a given code.
+ * @param aCode
+ * One of the codes from the kCharsetCodes table, representing the
+ * requested charset.
+ * @returns the requested character set name, or the default character set name
+ * if it doesn't exist.
+ */
+function getCharSetFromCode(aCode) {
+ if (kCharsetCodes[aCode])
+ return kCharsetCodes[aCode];
+
+ return getLocalizedPref("intl.charset.default", DEFAULT_QUERY_CHARSET);
+}
+
+/**
+ * Wrapper for nsIPrefBranch::getComplexValue.
+ * @param aPrefName
+ * The name of the pref to get.
+ * @returns aDefault if the requested pref doesn't exist.
+ */
+function getLocalizedPref(aPrefName, aDefault) {
+ var prefB = Cc["@mozilla.org/preferences-service;1"].
+ getService(Ci.nsIPrefBranch);
+ const nsIPLS = Ci.nsIPrefLocalizedString;
+ try {
+ return prefB.getComplexValue(aPrefName, nsIPLS).data;
+ } catch (ex) {}
+
+ return aDefault;
+}
+
+/**
+ * Wrapper for nsIPrefBranch::setComplexValue.
+ * @param aPrefName
+ * The name of the pref to set.
+ * @param aValue
+ * The value of the pref.
+ */
+function setLocalizedPref(aPrefName, aValue) {
+ var prefB = Cc["@mozilla.org/preferences-service;1"].
+ getService(Ci.nsIPrefBranch);
+ var pls = Cc["@mozilla.org/pref-localizedstring;1"].
+ createInstance(Ci.nsIPrefLocalizedString);
+ pls.data = aValue;
+ prefB.setComplexValue(aPrefName, Ci.nsIPrefLocalizedString, pls);
+}
+
+/**
+ * Wrapper for nsIPrefBranch::setBoolPref.
+ * @param aPrefName
+ * The name of the pref to set.
+ * @param aValue
+ * The value of the pref.
+ */
+function setBoolPref(aName, aVal) {
+ var prefB = Cc["@mozilla.org/preferences-service;1"].
+ getService(Ci.nsIPrefBranch);
+ prefB.setBoolPref(aName, aVal);
+}
+
+/**
+ * Wrapper for nsIPrefBranch::getBoolPref.
+ * @param aPrefName
+ * The name of the pref to get.
+ * @returns aDefault if the requested pref doesn't exist.
+ */
+function getBoolPref(aName, aDefault) {
+ var prefB = Cc["@mozilla.org/preferences-service;1"].
+ getService(Ci.nsIPrefBranch);
+ try {
+ return prefB.getBoolPref(aName);
+ } catch (ex) {
+ return aDefault;
+ }
+}
+
+/**
+ * Get a unique nsIFile object with a sanitized name, based on the engine name.
+ * @param aName
+ * A name to "sanitize". Can be an empty string, in which case a random
+ * 8 character filename will be produced.
+ * @param aExt
+ * A file extension to use for the file. If not provided, defaults to
+ * XML_FILE_EXT.
+ * @returns A nsIFile object in the user's search engines directory with a
+ * unique sanitized name.
+ */
+function getSanitizedFile(aName) {
+ var fileName = sanitizeName(aName) + "." + XML_FILE_EXT;
+ var file = getDir(NS_APP_USER_SEARCH_DIR);
+ file.append(fileName);
+ file.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, PERMS_FILE);
+ return file;
+}
+
+/**
+ * Removes all characters not in the "chars" string from aName.
+ *
+ * @returns a sanitized name to be used as a filename, or a random name if a
+ * sanitized name cannot be obtained (if aName contains no valid
+ * characters).
+ */
+function sanitizeName(aName) {
+ const chars = "abcdefghijklmnopqrstuvwxyz0123456789";
+ var name = aName.toLowerCase()
+ .split("").filter(function (el) {
+ return chars.indexOf(el) != -1;
+ }).join("");
+ if (!name) {
+ // Our input had no valid characters - use a random name
+ var cl = chars.length;
+ for (var i = 0; i < 8; ++i)
+ name += chars.charAt(Math.round(Math.random() * cl));
+ }
+ return name;
+}
+
+/**
+ * Notifies watchers of SEARCH_ENGINE_TOPIC about changes to an engine or to
+ * the state of the search service.
+ *
+ * @param aEngine
+ * The nsISearchEngine object to which the change applies.
+ * @param aVerb
+ * A verb describing the change.
+ *
+ * @see nsIBrowserSearchService.idl
+ */
+function notifyAction(aEngine, aVerb) {
+ var os = Cc["@mozilla.org/observer-service;1"].
+ getService(Ci.nsIObserverService);
+ LOG("NOTIFY: Engine: \"" + aEngine.name + "\"; Verb: \"" + aVerb + "\"");
+ os.notifyObservers(aEngine, SEARCH_ENGINE_TOPIC, aVerb);
+}
+
+/**
+ * Simple object representing a name/value pair.
+ * @throws NS_ERROR_NOT_IMPLEMENTED if the provided value includes unsupported
+ * parameters.
+ * @see kIllegalWords.
+ */
+function QueryParameter(aName, aValue) {
+ ENSURE_ARG(aName && aValue, "missing name or value for QueryParameter!");
+
+ ENSURE(!kIllegalWords.test(aValue),
+ "Illegal value while creating a QueryParameter",
+ Cr.NS_ERROR_NOT_IMPLEMENTED);
+
+ this.name = aName;
+ this.value = aValue;
+}
+
+/**
+ * Creates an engineURL object, which holds the query URL and all parameters.
+ *
+ * @param aType
+ * A string containing the name of the MIME type of the search results
+ * returned by this URL.
+ * @param aMethod
+ * The HTTP request method. Must be a case insensitive value of either
+ * "GET" or "POST".
+ * @param aTemplate
+ * The URL to which search queries should be sent. For GET requests,
+ * must contain the string "{searchTerms}", to indicate where the user
+ * entered search terms should be inserted.
+ *
+ * @see http://opensearch.a9.com/spec/1.1/querysyntax/#urltag
+ *
+ * @throws NS_ERROR_NOT_IMPLEMENTED if aType is unsupported, or if aTemplate
+ * includes unsupported parameters.
+ *
+ * @see kIllegalWords.
+ */
+function EngineURL(aType, aMethod, aTemplate) {
+ ENSURE_ARG(aType && aMethod && aTemplate,
+ "missing type, method or template for EngineURL!");
+
+ var method = aMethod.toUpperCase();
+ var type = aType.toLowerCase();
+
+ ENSURE_ARG(method == "GET" || method == "POST",
+ "method passed to EngineURL must be \"GET\" or \"POST\"");
+
+ ENSURE(type == "text/html", "EngineURLs must be of type text/html!",
+ Cr.NS_ERROR_NOT_IMPLEMENTED);
+
+ ENSURE(!kIllegalWords.test(aTemplate), "Invalid URL parameter!",
+ Cr.NS_ERROR_NOT_IMPLEMENTED);
+
+ this.type = type;
+ this.method = method;
+ this.template = aTemplate;
+ this.params = [];
+}
+EngineURL.prototype = {
+
+ addParam: function SRCH_EURL_addParam(aName, aValue) {
+ this.params.push(new QueryParameter(aName, aValue));
+ },
+
+ getSubmission: function SRCH_EURL_getSubmission(aData) {
+ /**
+ * From an array of QueryParameter objects, generates a string in the
+ * application/x-www-form-urlencoded format:
+ * name=value&name=value&name=value...
+ * @param aParams
+ * An array of QueryParameter objects
+ * @param aData
+ * Data to be substituted into parameter values using the
+ * |kValidWords| regexp
+ * @returns A string of encoded param names and values in
+ * application/x-www-form-urlencoded format.
+ */
+ function makeQueryString(aParams, aData) {
+ var str = "";
+ for (var i = 0; i < aParams.length; ++i) {
+ var param = aParams[i];
+ var value = param.value.replace(kValidWords, aData);
+ str += (i > 0 ? "&" : "") + param.name + "=" + value;
+ }
+ return str;
+ }
+
+ var url = this.template.replace(kValidWords, aData);
+ var postData = null;
+ var dataString = makeQueryString(this.params, aData);
+ if (this.method == "GET") {
+ // GET method requests have no post data, and append the encoded
+ // text to the url...
+ if (url.indexOf("?") == -1 && dataString)
+ url += "?";
+ url += dataString;
+ } else if (this.method == "POST") {
+ // POST method requests must wrap the encoded text in a MIME
+ // stream and supply that as POSTDATA.
+ var stringStream = Cc["@mozilla.org/io/string-input-stream;1"].
+ createInstance(Ci.nsIStringInputStream);
+ stringStream.data = dataString;
+
+ postData = Cc["@mozilla.org/network/mime-input-stream;1"].
+ createInstance(Ci.nsIMIMEInputStream);
+ postData.addHeader("Content-Type", "application/x-www-form-urlencoded");
+ postData.addContentLength = true;
+ postData.setData(stringStream);
+ }
+
+ return new Submission(makeURI(url), postData);
+ },
+
+ /**
+ * Serializes the engine object to a OpenSearch Url element.
+ * @param aDoc
+ * The document to use to create the Url element.
+ * @param aElement
+ * The element to which the created Url element is appended.
+ *
+ * @see http://opensearch.a9.com/spec/1.1/querysyntax/#urltag
+ */
+ _serializeToElement: function SRCH_EURL_serializeToEl(aDoc, aElement) {
+ var url = aDoc.createElementNS(kOpenSearchNS_11, "Url");
+ url.setAttribute("type", this.type);
+ url.setAttribute("method", this.method);
+ url.setAttribute("template", this.template);
+
+ for (var i = 0; i < this.params.length; ++i) {
+ var param = aDoc.createElementNS(kOpenSearchNS_11, "Param");
+ param.setAttribute("name", this.params[i].name);
+ param.setAttribute("value", this.params[i].value);
+ url.appendChild(aDoc.createTextNode("\n "));
+ url.appendChild(param);
+ }
+ url.appendChild(aDoc.createTextNode("\n"));
+ aElement.appendChild(url);
+ }
+};
+
+/**
+ * nsISearchEngine constructor.
+ * @param aLocation
+ * A nsILocalFile or nsIURI object representing the location of the
+ * search engine data file.
+ * @param aSourceDataType
+ * The data type of the file used to describe the engine. Must be either
+ * DATA_XML or DATA_TEXT.
+ * @param aIsReadOnly
+ * Boolean indicating whether the engine should be treated as read-only.
+ * Read only engines cannot be serialized to file.
+ */
+function Engine(aLocation, aSourceDataType, aIsReadOnly) {
+ this._dataType = aSourceDataType;
+ this._readOnly = aIsReadOnly;
+ this._urls = [];
+
+ if (aLocation instanceof Ci.nsILocalFile) {
+ ENSURE(aLocation.exists(),
+ "Can't init an engine from a non-existent file!",
+ Cr.NS_ERROR_FAILURE);
+
+ // we already have a file (e.g. loading engines from disk)
+ this._file = aLocation;
+ this._getData();
+
+ // parse the data and set up fields accordingly
+ this._init();
+ } else if (aLocation instanceof Ci.nsIURI) {
+ this._uri = aLocation;
+ switch (aLocation.scheme) {
+ case "https":
+ case "http":
+ case "data":
+ case "file":
+ case "resource":
+ // we have a URI, and no file
+ this._getDataFromURI(aLocation);
+ break;
+ case "javascript":
+ // Passing a javascript URI to addEngine causes a crash (bug 328697).
+ // Fall through...
+ default:
+ ERROR("Invalid URI passed to the nsISearchEngine constructor",
+ Cr.NS_ERROR_INVALID_ARG);
+ }
+ } else
+ ERROR("Engine location is neither a File nor a URI object",
+ Cr.NS_ERROR_INVALID_ARG);
+}
+
+Engine.prototype = {
+ // The engine's alias.
+ _alias: null,
+ // The data describing the engine. Is either an array of lines, for Sherlock
+ // files, or an XML document element, for XML plugins.
+ _data: null,
+ // The engine's data type. See data types (DATA_) defined above.
+ _dataType: null,
+ // Whether or not the engine is readonly.
+ _readOnly: true,
+ // The engine's description
+ _description: "",
+ // The file from which the plugin was loaded.
+ _file: null,
+ // Whether the engine is hidden from the user.
+ _hidden: null,
+ // The XMLHTTPRequest object used to download the engine.
+ // (null for engines loaded from disk)
+ _req: null,
+ // The engine's name.
+ _name: null,
+ // The engine type. See engine types (TYPE_) defined above.
+ _type: null,
+ // The name of the charset used to submit the search terms.
+ _queryCharset: null,
+ // The URI object from which the engine was retrieved.
+ // This is null for local plugins, and is only used for error messages and
+ // logging.
+ _uri: null,
+
+ /**
+ * Retrieves the data from the engine's file. If the engine's dataType is
+ * XML, the document element is placed in the engine's data field. For text
+ * engines, the data is just read directly from file and placed as an array
+ * of lines in the engine's data field.
+ */
+ _getData: function SRCH_ENG_getData() {
+ var fileInStream = Cc["@mozilla.org/network/file-input-stream;1"].
+ createInstance(Ci.nsIFileInputStream);
+
+ fileInStream.init(this._file, MODE_RDONLY, PERMS_FILE, false);
+
+ switch (this._dataType) {
+ case Ci.nsISearchEngine.DATA_XML:
+
+ var domParser = Cc["@mozilla.org/xmlextras/domparser;1"].
+ createInstance(Ci.nsIDOMParser);
+ var doc = domParser.parseFromStream(fileInStream, "UTF-8",
+ this._file.fileSize,
+ "text/xml");
+
+ this._data = doc.documentElement;
+ break;
+ case Ci.nsISearchEngine.DATA_TEXT:
+ fileInStream.QueryInterface(Ci.nsILineInputStream);
+
+ var line = { value: "" };
+ var more = false;
+ var lines = [];
+
+ do {
+ more = fileInStream.readLine(line);
+ // Filter out comments and whitespace-only lines
+ if (!(kUselessLine.test(line.value)))
+ lines.push(line.value);
+ } while (more);
+
+ this._data = lines;
+
+ break;
+ default:
+ ERROR("Bogus engine _dataType: \"" + this._dataType + "\"",
+ Cr.NS_ERROR_UNEXPECTED);
+ }
+
+ fileInStream.close();
+ },
+
+ /**
+ * Retrieves the engine data from a URI.
+ * @param aURI
+ * The URL to transfer from.
+ */
+ _getDataFromURI: function SRCH_ENG_getDataFromURI(aURI) {
+ ENSURE_ARG(aURI instanceof Ci.nsIURI, "Invalid URI for _getDataFromURI!");
+
+ LOG("_getDataFromURI: Downloading engine from: \"" + aURI.spec + "\".");
+ var mimeType = "";
+ switch (this._dataType) {
+ case Ci.nsISearchEngine.DATA_XML:
+ mimeType = "text/xml";
+ break;
+ case Ci.nsISearchEngine.DATA_TEXT:
+ mimeType = "text/plain";
+ break;
+ default:
+ ERROR("Bogus engine _dataType: \"" + this._dataType + "\"",
+ Cr.NS_ERROR_UNEXPECTED);
+ }
+
+ this._req = Cc["@mozilla.org/xmlextras/xmlhttprequest;1"].
+ createInstance(Ci.nsIXMLHttpRequest);
+ this._req.open("GET", aURI.spec, true);
+ this._req.overrideMimeType(mimeType);
+ this._req.setRequestHeader("Cache-Control", "no-cache");
+
+ var self = this;
+ this._req.send(null);
+ this._req.onerror = function (event) { self._onError(event); };
+ this._req.onload = function (event) { self._onLoad(event); };
+ },
+
+ /**
+ * Handle an error during the load of an engine by prompting the user to
+ * notify him that the load failed.
+ */
+ _onError: function SRCH_ENG_onError(aEvent) {
+ 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_msg",
+ [brandName, this._location],
+ 2);
+
+ var ww = Cc["@mozilla.org/embedcomp/window-watcher;1"].
+ getService(Ci.nsIWindowWatcher);
+ ww.getNewPrompter(null).alert(title, text);
+ },
+
+ /**
+ * Handle the successful download of an engine. Initializes the engine and
+ * triggers parsing of the data. The engine is then flushed to disk. Notifies
+ * the search service once initialization is complete.
+ */
+ _onLoad: function SRCH_ENG_onLoad(aEvent) {
+
+ var httpChannel = this._req.channel.QueryInterface(Ci.nsIHttpChannel);
+ if (this._req.readyState != 4 || !httpChannel.requestSucceeded) {
+ this._onError();
+ LOG("_onLoad: Request for " + this._location + " failed!");
+ return;
+ }
+
+ switch (this._dataType) {
+ case Ci.nsISearchEngine.DATA_XML:
+ this._data = this._req.responseXML.documentElement;
+ break;
+ case Ci.nsISearchEngine.DATA_TEXT:
+ this._data = this._req.responseText.split(/(\r\n|\n\r|\r|\n)/);
+
+ // Filter out comments and whitespace-only lines.
+ this._data.filter(function (line) {
+ return (!kUselessLine.test(line));
+ });
+ break;
+ default:
+ this._onError();
+ LOG("_onLoad: Bogus engine _dataType: \"" + this._dataType + "\"");
+ return;
+ }
+ try {
+ // Initialize the engine from the obtained data
+ this._init();
+ } catch (ex) {
+ // Report an error to the user
+ LOG("_onLoad: Failed to init engine!\n" + ex);
+ this._onError();
+ return;
+ }
+
+ // Write the engine to file
+ this._serializeToFile();
+
+ // Notify the search service of the sucessful load
+ notifyAction(this, SEARCH_ENGINE_LOADED);
+ },
+
+ /**
+ * Sets the .iconURI property of the engine.
+ *
+ * @param aIconURL
+ * A URI string pointing to the engine's icon. Must have a http[s] or
+ * data scheme. Icons with HTTP[S] schemes will be downloaded and
+ * converted to data URIs for storage in the engine XML files, if
+ * the engine is not readonly.
+ */
+ _setIcon: function SRCH_ENG_setIcon(aIconURL) {
+
+ var uri = makeURI(aIconURL);
+
+ // Ignore bad URIs
+ if (!uri)
+ return;
+
+ LOG("_setIcon: Setting icon url \"" + uri.spec + "\" for engine \""
+ + this.name + "\".");
+ // Only accept remote icons from http[s]
+ switch (uri.scheme) {
+ case "data":
+ this._iconURI = uri;
+ break;
+ case "http":
+ case "https":
+ // No use downloading the icon if the engine file is read-only
+ // XXX could store the data: URI in a pref... ew?
+ if (!this._readOnly) {
+ LOG("_setIcon: Downloading icon: \"" + uri.spec +
+ "\" for engine: \"" + this.name + "\"");
+ var ios = Cc["@mozilla.org/network/io-service;1"].
+ getService(Ci.nsIIOService);
+ var chan = ios.newChannelFromURI(uri);
+ var listener = new iconLoadListener(chan, this);
+ chan.notificationCallbacks = listener;
+ chan.asyncOpen(listener, null);
+ }
+ break;
+ }
+ },
+
+ /**
+ * Initialize this Engine object from the collected data.
+ */
+ _init: function SRCH_ENG_init() {
+
+ ENSURE_WARN(this._data, "Can't init an engine with no data!",
+ Cr.NS_ERROR_UNEXPECTED);
+
+ // Find out what type of engine we are
+ switch (this._dataType) {
+ case Ci.nsISearchEngine.DATA_XML:
+ if (checkNameSpace(this._data, [kMozSearchLocalName],
+ [kMozSearchNS_10])) {
+
+ LOG("_init: Initing MozSearch plugin from " + this._location);
+
+ this._type = Ci.nsISearchEngine.TYPE_MOZSEARCH;
+ this._parseAsMozSearch();
+
+ } else if (checkNameSpace(this._data, [kOpenSearchLocalName],
+ [kOpenSearchNS_11, kOpenSearchNS_10])) {
+
+ LOG("_init: Initing OpenSearch plugin from " + this._location);
+
+ this._type = Ci.nsISearchEngine.TYPE_OPENSEARCH;
+ this._parseAsOpenSearch();
+
+ } else
+ ENSURE(false, this._location + " is not a valid search plugin.",
+ Cr.NS_ERROR_FAILURE);
+
+ break;
+ case Ci.nsISearchEngine.DATA_TEXT:
+ LOG("_init: Initing Sherlock plugin from " + this._location);
+
+ // the only text-based format we support is Sherlock
+ this._type = Ci.nsISearchEngine.TYPE_SHERLOCK;
+ this._parseAsSherlock();
+ }
+
+ // If we don't yet have a file (i.e. we instantiated an engine object from
+ // passed in URL), get one now
+ if (!this._file)
+ this._file = getSanitizedFile(this.name);
+
+ // Generate a unique ID for this engine. Use the name of the engine, URI
+ // encoded because pref names can only contain certain characters
+ this._pref = BROWSER_SEARCH_PREF + "engine." +
+ encodeURIComponent(this.name) + ".";
+ },
+
+ /**
+ * Initialize this Engine object from a collection of metadata.
+ */
+ _initFromMetadata: function SRCH_ENG_initMetaData(aName, aIconURL, aAlias,
+ aDescription, aMethod,
+ aTemplate) {
+ ENSURE_WARN(!this._readOnly,
+ "Can't call _initFromMetaData on a readonly engine!",
+ Cr.NS_ERROR_FAILURE);
+
+ this._name = aName;
+ this._alias = aAlias;
+ this._description = aDescription;
+ this._setIcon(aIconURL);
+
+ this._urls.push(new EngineURL("text/html", aMethod, aTemplate));
+
+ this._serializeToFile();
+ },
+
+ /**
+ * Extracts data from an OpenSearch URL element and creates an EngineURL
+ * object which is then added to the engine's list of URLs.
+ *
+ * @see http://opensearch.a9.com/spec/1.1/querysyntax/#urltag.
+ * @see EngineURL()
+ */
+ _parseURL: function SRCH_ENG_parseURL(aElement) {
+ var type = aElement.getAttribute("type");
+ var method = aElement.getAttribute("method");
+ var template = aElement.getAttribute("template");
+
+ var url = new EngineURL(type, method, template);
+
+ for (var i = 0; i < aElement.childNodes.length; ++i) {
+ var param = aElement.childNodes[i];
+ if (param.localName == "Param")
+ url.addParam(param.getAttribute("name"), param.getAttribute("value"));
+ }
+ this._urls.push(url);
+ },
+
+ /**
+ * Get the icon from an OpenSearch Image element.
+ * @see http://opensearch.a9.com/spec/1.1/description/#image
+ */
+ _parseImage: function SRCH_ENG_parseImage(aElement) {
+ LOG("_parseImage: Image textContent: \"" + aElement.textContent + "\"");
+ if (aElement.getAttribute("width") == "16" &&
+ aElement.getAttribute("height") == "16") {
+ this._setIcon(aElement.textContent);
+ }
+ },
+
+ _parseAsMozSearch: function SRCH_ENG_parseAsMoz() {
+ //XXX for now, just forward to the OpenSearch parser
+ this._parseAsOpenSearch();
+ },
+
+ /**
+ * Extract search engine information from the collected data to initialize
+ * the engine object.
+ */
+ _parseAsOpenSearch: function SRCH_ENG_parseAsOS() {
+ var doc = this._data;
+ for (var i = 0; i < doc.childNodes.length; ++i) {
+ var child = doc.childNodes[i];
+ switch (child.localName) {
+ case "ShortName":
+ this._name = child.textContent;
+ break;
+ case "Description":
+ this._description = child.textContent;
+ break;
+ case "Url":
+ this._parseURL(child);
+ break;
+ case "Image":
+ this._parseImage(child);
+ break;
+ case "Alias":
+ this._alias = child.textContent;
+ break;
+ case "InputEncoding":
+ this._queryCharset = child.textContent.toUpperCase();
+ break;
+ }
+ }
+ ENSURE(this.name && (this._urls.length > 0),
+ "_parseAsOpenSearch: No name, or missing URL!",
+ Cr.NS_ERROR_FAILURE);
+ },
+
+ /**
+ * Extract search engine information from the collected data to initialize
+ * the engine object.
+ */
+ _parseAsSherlock: function SRCH_ENG_parseAsSherlock() {
+ /**
+ * Trims leading and trailing whitespace from aStr.
+ */
+ function sTrim(aStr) {
+ return aStr.replace(/^\s+/g, "").replace(/\s+$/g, "");
+ }
+
+ /**
+ * Extracts one Sherlock "section" from aSource. A section is essentially
+ * an HTML element with attributes, but each attribute must be on a new
+ * line, by definition.
+ *
+ * @param aLines
+ * An array of lines from the sherlock file.
+ * @param aSection
+ * The name of the section (e.g. "search" or "browser"). This value
+ * is not case sensitive.
+ * @returns an object whose properties correspond to the section's
+ * attributes.
+ */
+ function getSection(aLines, aSection) {
+ LOG("_parseAsSherlock::getSection: Sherlock lines:\n" +
+ aLines.join("\n"));
+ var lines = aLines;
+ var startMark = new RegExp("^\\s*<" + aSection.toLowerCase() + "\\s*",
+ "gi");
+ var endMark = /\s*>\s*$/gi;
+
+ var foundStart = false;
+ var startLine, numberOfLines;
+ // Find the beginning and end of the section
+ for (var i=0; i" characters
+ value = value.replace(/^["']/, "")
+ .replace(/["']\s*[\\\/]?>?\s*$/, "") || "";
+ value = sTrim(value);
+
+ // Don't clobber existing attributes
+ if (!(name in section))
+ section[name] = value;
+ }
+ return section;
+ }
+
+ /**
+ * Returns an array of name-value pair arrays representing the Sherlock
+ * file's input elements. User defined inputs return kUserDefined as the
+ * value. Elements are returned in the order they appear in the source
+ * file.
+ *
+ * Example:
+ *
+ *
+ * Returns:
+ * [["foo", "bar"], ["foopy", "{searchTerms}"]]
+ *
+ * @param aLines
+ * An array of lines from the source file.
+ */
+ function getInputs(aLines) {
+
+ /**
+ * Extracts an attribute value from a given a line of text.
+ * Example:
+ * Extracts the string |foo| or |bar| given an input aAttr of
+ * |value| or |name|.
+ * Attributes may be quoted or unquoted. If unquoted, any whitespace
+ * indicates the end of the attribute value.
+ * Example: < value=22 33 name=44\334 >
+ * Returns |22| for "value" and |44\334| for "name".
+ *
+ * @param aAttr
+ * The name of the attribute for which to obtain the value. This
+ * value is not case sensitive.
+ * @param aLine
+ * The line containing the attribute.
+ *
+ * @returns the attribute value, or an empty string if the attribute
+ * doesn't exist.
+ */
+ function getAttr(aAttr, aLine) {
+ LOG("_parseAsSherlock::getAttr: Getting attr: \"" +
+ aAttr + "\" for line: \"" + aLine + "\"");
+ // We're not case sensitive, but we want to return the attribute value
+ // in it's original case, so create a copy of the source
+ var lLine = aLine.toLowerCase();
+ var attr = aAttr.toLowerCase();
+
+ var attrStart = lLine.search(new RegExp("\\s" + attr, "i"));
+ if (attrStart == -1) {
+ // If this is the "user defined input" (i.e. contains the empty
+ // "user" attribute), return our special keyword
+ if (kIsUserInput.test(lLine) && attr == "value") {
+ LOG("_parseAsSherlock::getAttr: Found user input!\nLine:\"" + lLine
+ + "\"");
+ return kUserDefined;
+ }
+ // The attribute doesn't exist - ignore
+ LOG("_parseAsSherlock::getAttr: Failed to find attribute:\nLine:\""
+ + lLine + "\"\nAttr:\"" + attr + "\"");
+ return "";
+ }
+
+ var valueStart = lLine.indexOf("=", attrStart) + "=".length;
+ if (valueStart == -1)
+ return "";
+
+ var quoteStart = lLine.indexOf("\"", valueStart);
+ if (quoteStart == -1) {
+
+ // Unquoted attribute, get the rest of the line, trimmed at the first
+ // sign of whitespace. If the rest of the line is only whitespace,
+ // returns a blank string.
+ return lLine.substr(valueStart).replace(/\s.*$/, "");
+
+ } else {
+ // Make sure that there's only whitespace between the start of the
+ // value and the first quote. If there is, end the attribute value at
+ // the first sign of whitespace. This prevents us from falling into
+ // the next attribute if this is an unquoted attribute followed by a
+ // quoted attribute.
+ var betweenEqualAndQuote = lLine.substring(valueStart, quoteStart);
+ if (/\S/.test(betweenEqualAndQuote))
+ return lLine.substr(valueStart).replace(/\s.*$/, "");
+
+ // Adjust the start index to account for the opening quote
+ valueStart = quoteStart + "\"".length;
+ // Find the closing quote
+ valueEnd = lLine.indexOf("\"", valueStart);
+ // If there is no closing quote, just go to the end of the line
+ if (valueEnd == -1)
+ valueEnd = aLine.length;
+ }
+ return aLine.substring(valueStart, valueEnd);
+ }
+
+ var inputs = [];
+
+ LOG("_parseAsSherlock::getInputs: Lines:\n" + aLines);
+ // Filter out everything but non-inputs
+ lines = aLines.filter(function (line) {
+ return /^\s*")
+ line = sTrim(line).replace(/^$/, "");
+
+ // If this is one of the "directional" inputs (/)
+ const directionalInput = /^(prev|next)/i;
+ if (directionalInput.test(line)) {
+
+ // Make it look like a normal input by removing "prev" or "next"
+ line = line.replace(directionalInput, "");
+
+ // If it has a name, give it a dummy value to match previous
+ // nsInternetSearchService behavior
+ if (/name\s*=/i.test(line)) {
+ line += " value=\"0\"";
+ } else
+ return; // Line has no name, skip it
+ }
+
+ var attrName = getAttr("name", line);
+ var attrValue = getAttr("value", line);
+ LOG("_parseAsSherlock::getInputs: Got input:\nName:\"" + attrName +
+ "\"\nValue:\"" + attrValue + "\"");
+ if (attrValue)
+ inputs.push([attrName, attrValue]);
+ });
+ return inputs;
+ }
+
+ function err(aErr) {
+ LOG("_parseAsSherlock::err: Sherlock param error:\n" + aErr);
+ throw Cr.NS_ERROR_FAILURE;
+ }
+
+ var searchSection = getSection(this._data, "search");
+ LOG("_parseAsSherlock: Search section:\n" + searchSection.toSource());
+
+ this._name = searchSection["name"] || err("Missing name!");
+ this._description = searchSection["description"] || "";
+ this._queryCharset = searchSection["querycharset"] ||
+ getCharSetFromCode(searchSection["queryencoding"]);
+
+ // XXX should this really fall back to GET?
+ var method = (searchSection["method"] || "GET").toUpperCase();
+ var template = searchSection["action"] || err("Missing action!");
+
+ var inputs = getInputs(this._data);
+ LOG("_parseAsSherlock: Inputs:\n" + inputs.toSource());
+
+ var url = null;
+
+ if (method == "GET") {
+ // Here's how we construct the input string:
+ // is first: Name Attr: Prefix Data Example:
+ // YES EMPTY None TEMPLATE
+ // YES NON-EMPTY ? = TEMPLATE?=
+ // NO EMPTY ------------- --------------
+ // NO NON-EMPTY & = TEMPLATE?=&=
+ for (var i=0; i
-
# -*- Mode: HTML -*-
# ***** BEGIN LICENSE BLOCK *****
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
#
# The contents of this file are subject to the Mozilla Public License Version
# 1.1 (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
# http://www.mozilla.org/MPL/
@@ -17,479 +16,430 @@
# The Original Code is mozilla.org browser.
#
# The Initial Developer of the Original Code is
# Joe Hewitt.
# Portions created by the Initial Developer are Copyright (C) 2003
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
-# Pierre Chanial V 2.0 (p_ch@verizon.net)
-# Gavin Sharp (gavin@gavinsharp.com)
+# Pierre Chanial (v2)
+# Gavin Sharp (v3)
+# Ben Goodger
#
# Alternatively, the contents of this file may be used under the terms of
# either the GNU General Public License Version 2 or later (the "GPL"), or
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
# in which case the provisions of the GPL or the LGPL are applicable instead
# of those above. If you wish to allow use of your version of this file only
# under the terms of either the GPL or the LGPL, and not to allow others to
# use your version of this file under the terms of the MPL, indicate your
# decision by deleting the provisions above and replace them with the notice
# and other provisions required by the GPL or the LGPL. If you do not delete
# the provisions above, a recipient may use your version of this file under
# the terms of any one of the MPL, the GPL or the LGPL.
#
# ***** END LICENSE BLOCK *****
+ xmlns="http://www.mozilla.org/xbl"
+ xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
+ xmlns:xbl="http://www.mozilla.org/xbl">
-
+
-
+
-
-
+
-
-
-
-
-
-
+
+
-
- document.getAnonymousNodes(this)[0]
- document.getAnonymousNodes(this)[1]
+
+
+
+
+
+
+ document.getAnonymousNodes(this)[0];
+ document.getAnonymousNodes(this)[1];
+
+ document.getAnonymousElementByAttribute(this,
+ "anonid",
+ "searchbar-popup");
+
+ null
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ = 0 && nextIndex < engines.length)
+ this.currentEngine = engines[nextIndex];
+ break;
+ }
+ }
+ }
+ aEvent.preventDefault();
+ aEvent.stopPropagation();
+ ]]>
+
+
+
+
+
+
+
-
+
-
-
-
- var textBox = document.getAnonymousElementByAttribute(this,
- "anonid", "textbox-input-box");
- return document.getAnonymousElementByAttribute(textBox,
- "anonid", "input-box-contextmenu");
-
-
+ this.parentNode._stringBundle
+
+
-
+ cxmenu.appendChild(element);
-
-
-
- Components.interfaces.nsIPrefLocalizedString;
-
- this.parentNode.mStringBundle
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- // overload |onTextEntered| in autocomplete.xml
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+ })]]>
-
-
+ })]]>
+
+
+
-
-
-
-
-
-
-
#ifndef XP_MACOSX
-
#endif
-
-
-
-
nsDragAndDrop.drop(event, this.searchbarDNDObserver);
-
-
-
+
+
-
+
-
+
Index: browser/components/search/content/searchDialog.css
===================================================================
RCS file: browser/components/search/content/searchDialog.css
diff -N browser/components/search/content/searchDialog.css
--- browser/components/search/content/searchDialog.css 18 Feb 2006 00:13:43 -0000 1.2
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,53 +0,0 @@
-/* ***** BEGIN LICENSE BLOCK *****
-%if 0
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is Mozilla Search Dialog.
- *
- * The Initial Developer of the Original Code is
- * Gavin Sharp .
- * Portions created by the Initial Developer are Copyright (C) 2005
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
-%endif
- * ***** END LICENSE BLOCK ***** */
-
-#searchEngineList {
- min-height: 24px;
-}
-
-.engine-icon > .menulist-label-box > .menulist-icon,
-.engine-icon > .menu-iconic-left > .menu-iconic-icon {
- width: 16px;
- height: 16px;
- min-height: 16px;
-}
-
-.engine-icon > .menu-iconic-left {
- display: -moz-box;
- min-height: 16px;
-}
Index: browser/components/search/content/searchDialog.js
===================================================================
RCS file: browser/components/search/content/searchDialog.js
diff -N browser/components/search/content/searchDialog.js
--- browser/components/search/content/searchDialog.js 18 Feb 2006 00:13:43 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,211 +0,0 @@
-#if 0
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is Mozilla Search Dialog.
- *
- * The Initial Developer of the Original Code is
- * Gavin Sharp .
- * Portions created by the Initial Developer are Copyright (C) 2005
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- * Pierre Chanial
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the LGPL or the GPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-#endif
-
-var gDialog = {};
-var gSelectedEngineIndex;
-
-const kTabPref = "browser.tabs.opentabfor.searchdialog";
-const kEnginePref = "browser.search.selectedEngineInDialog";
-const kDefEnginePref = "browser.search.defaultenginename";
-const nsIPLS = Components.interfaces.nsIPrefLocalizedString;
-const kXUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
-
-function onLoad() {
- setTimeout(onAfterLoad, 0);
-}
-
-function onAfterLoad() {
-
- gDialog.list = document.getElementById("searchEngineList");
- gDialog.list.addEventListener("ValueChange", onEnginesListValueChange, false);
- gDialog.input = document.getElementById("searchInput");
- gDialog.newtab = document.getElementById("searchInNewTab");
- gDialog.searchbundle = document.getElementById("searchbarBundle");
- gDialog.browserbundle = document.getElementById("browserBundle");
-
- var el = document.getAnonymousElementByAttribute(gDialog.input, "anonid",
- "textbox-input-box");
- gDialog.contextmenu = document.getAnonymousElementByAttribute(el,
- "anonid", "input-box-contextmenu");
-
- var pref = Components.classes["@mozilla.org/preferences-service;1"]
- .getService(Components.interfaces.nsIPrefBranch2);
-
- var selectedEngine;
- var tabChecked = false;
- try {
- selectedEngine = pref.getComplexValue(kEnginePref, nsIPLS).data;
- } catch (ex) {
- selectedEngine = pref.getComplexValue(kDefEnginePref, nsIPLS).data;
- }
- try {
- tabChecked = pref.getBoolPref(kTabPref);
- } catch (ex) { }
-
- gDialog.newtab.setAttribute("checked", tabChecked);
-
- for (var i=0; i < gDialog.list.menupopup.childNodes.length; i++) {
- var label = gDialog.list.menupopup.childNodes[i].getAttribute("label");
- if (label == selectedEngine)
- gDialog.list.selectedIndex = i;
- }
-
- // Make sure we have a selected item
- if (gDialog.list.selectedIndex == -1)
- gDialog.list.selectedIndex = 0;
-
- gSelectedEngineIndex = gDialog.list.selectedIndex;
-
- // Add "Clear Search History" item to the text box context menu
- var sep = document.createElementNS(kXUL_NS, "menuseparator");
- gDialog.contextmenu.appendChild(sep);
-
- var element = document.createElementNS(kXUL_NS, "menuitem");
-
- var label = gDialog.searchbundle.getString("cmd_clearHistory");
- var accesskey = gDialog.searchbundle.getString("cmd_clearHistory_accesskey");
- element.setAttribute("label", label);
- element.setAttribute("accesskey", accesskey);
- element.setAttribute("cmd", "cmd_clearhistory");
-
- gDialog.contextmenu.appendChild(element);
- gDialog.input.controllers.appendController(clearHistoryController);
-}
-
-function onEnginesListValueChange() {
- if (gDialog.list.value == "addengines") {
- var url = gDialog.browserbundle.getString("searchEnginesURL");
- window.opener.openNewWindowWith(url, null, false);
- gDialog.list.selectedIndex = gSelectedEngineIndex;
- } else {
- gSelectedEngineIndex = gDialog.list.selectedIndex;
- }
-}
-
-function updateAddEnginesItem(aAdd) {
- // Remove the old item if it exists
- var elem = document.getElementById("addenginemenuitem");
- var sep = document.getElementById("addenginesep");
- if (elem)
- gDialog.list.menupopup.removeChild(elem);
- if (sep)
- gDialog.list.menupopup.removeChild(sep);
-
- if (aAdd) {
- // Add "Add Engines" item to the drop down
- var sep = document.createElementNS(kXUL_NS, "menuseparator");
- sep.setAttribute("id", "addenginesep");
- gDialog.list.menupopup.appendChild(sep);
-
- var label = gDialog.searchbundle.getString("cmd_addEngine");
- var newItem = gDialog.list.appendItem(label, "addengines");
- newItem.setAttribute("id", "addenginemenuitem");
- newItem.setAttribute("class", "menuitem-iconic engine-icon");
- }
-}
-
-function onDialogAccept() {
- var searchText = gDialog.input.value;
- var engine = gDialog.list.value;
- var searchURL;
-
- var searchSvc =
- Components.classes["@mozilla.org/rdf/datasource;1?name=internetsearch"]
- .getService(Components.interfaces.nsIInternetSearchService);
-
- // XXX Bug 269994: Use dummy string if there is no user entered string
- searchURL = searchSvc.GetInternetSearchURL(engine,
- searchText ? encodeURIComponent(searchText):"A",
- 0, 0, {value:0});
-
- if (searchText) {
- // Add item to form history
- var frmHistSvc = Components.classes["@mozilla.org/satchel/form-history;1"]
- .getService(Components.interfaces.nsIFormHistory);
- frmHistSvc.addEntry("searchbar-history", searchText);
- } else {
- try {
- // Get the engine's base URL
- searchURL = makeURI(searchURL).host;
- } catch (ex) {}
- }
-
- setPrefs();
- gDialog.input.controllers.removeController(clearHistoryController);
-
- window.opener.delayedSearchLoadURL(searchURL, gDialog.newtab.checked);
-
- // Delay closing slightly to avoid timing bug on Linux.
- window.close();
- return false;
-}
-
-function setPrefs() {
- var pref = Components.classes["@mozilla.org/preferences-service;1"]
- .getService(Components.interfaces.nsIPrefBranch2);
-
- var pls = Components.classes["@mozilla.org/pref-localizedstring;1"]
- .createInstance(nsIPLS);
-
- var name = gDialog.list.selectedItem.getAttribute("label");
- pls.data = name;
-
- pref.setComplexValue(kEnginePref, nsIPLS, pls);
- pref.setBoolPref(kTabPref, gDialog.newtab.checked);
-}
-
-var clearHistoryController = {
- frmHistSvc: Components.classes["@mozilla.org/satchel/form-history;1"]
- .getService(Components.interfaces.nsIFormHistory),
-
- autocompleteSearchParam: "searchbar-history",
-
- supportsCommand: function (aCommand) {
- return aCommand == "cmd_clearhistory";
- },
-
- isCommandEnabled: function (aCommand) {
- return this.frmHistSvc.nameExists(this.autocompleteSearchParam);
- },
-
- doCommand: function (aCommand) {
- this.frmHistSvc.removeEntriesForName(this.autocompleteSearchParam);
- gDialog.input.value = "";
- }
-}
Index: browser/components/search/content/searchDialog.xul
===================================================================
RCS file: browser/components/search/content/searchDialog.xul
diff -N browser/components/search/content/searchDialog.xul
--- browser/components/search/content/searchDialog.xul 18 Feb 2006 00:13:43 -0000 1.2
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,110 +0,0 @@
-
-
-
-
-
-
-
-
-
-
Index: browser/components/search/content/searchbarBindings.css
===================================================================
RCS file: /cvsroot/mozilla/browser/components/search/content/searchbarBindings.css,v
retrieving revision 1.2
diff -u -p -8 -r1.2 searchbarBindings.css
--- browser/components/search/content/searchbarBindings.css 18 Feb 2006 00:13:43 -0000 1.2
+++ browser/components/search/content/searchbarBindings.css 17 Mar 2006 07:08:45 -0000
@@ -1,11 +1,10 @@
@namespace url("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul");
.searchbar-textbox {
- -moz-binding: url("chrome://browser/content/search.xml#searchbar-textbox");
+ -moz-binding: url("chrome://browser/content/search/search.xml#searchbar-textbox");
}
.searchbar-dropmarker {
- -moz-binding: url("chrome://browser/content/search.xml#searchbar-dropmarker");
+ -moz-binding: url("chrome://browser/content/search/search.xml#searchbar-dropmarker");
-moz-user-focus: none;
}
-
Index: browser/components/sidebar/src/nsSidebar.js
===================================================================
RCS file: /cvsroot/mozilla/browser/components/sidebar/src/nsSidebar.js,v
retrieving revision 1.11
diff -u -p -8 -r1.11 nsSidebar.js
--- browser/components/sidebar/src/nsSidebar.js 17 Oct 2005 11:32:16 -0000 1.11
+++ browser/components/sidebar/src/nsSidebar.js 17 Mar 2006 07:08:45 -0000
@@ -123,16 +123,17 @@ function (aTitle, aContentURL, aCustomiz
/* decorate prototype to provide ``class'' methods and property accessors */
nsSidebar.prototype.addSearchEngine =
function (engineURL, iconURL, suggestedTitle, suggestedCategory)
{
debug("addSearchEngine(" + engineURL + ", " + iconURL + ", " +
suggestedCategory + ", " + suggestedTitle + ")");
+ // XXXBug 312560: Localize me!
try
{
// make sure using HTTP or HTTPS and refering to a .src file
// for the engine.
if (! /^https?:\/\/.+\.src$/i.test(engineURL))
throw "Unsupported search engine URL";
// make sure using HTTP or HTTPS and refering to a
@@ -149,41 +150,36 @@ function (engineURL, iconURL, suggestedT
var titleMessage, dialogMessage;
try {
var stringBundle = srGetStrBundle("chrome://browser/locale/sidebar/sidebar.properties");
if (stringBundle) {
titleMessage = stringBundle.GetStringFromName("addEngineConfirmTitle");
dialogMessage = stringBundle.GetStringFromName("addEngineConfirmMessage");
dialogMessage = dialogMessage.replace(/%title%/, suggestedTitle);
- dialogMessage = dialogMessage.replace(/%category%/, suggestedCategory);
dialogMessage = dialogMessage.replace(/%url%/, engineURL);
dialogMessage = dialogMessage.replace(/#/g, "\n");
}
}
catch (e) {
titleMessage = "Add Search Engine";
dialogMessage = "Add the following search engine?\n\nName: " + suggestedTitle;
- dialogMessage += "\nSearch Category: " + suggestedCategory;
dialogMessage += "\nSource: " + engineURL;
}
var rv = this.promptService.confirm(null, titleMessage, dialogMessage);
if (!rv)
return;
- var internetSearch = Components.classes[NETSEARCH_CONTRACTID].getService();
- if (internetSearch)
- internetSearch = internetSearch.QueryInterface(nsIInternetSearchService);
- if (internetSearch)
- {
- internetSearch.AddSearchEngine(engineURL, iconURL, suggestedTitle,
- suggestedCategory);
- }
+ var searchService = Components.classes["@mozilla.org/browser/search-service;1"]
+ .getService(Components.interfaces.nsIBrowserSearchService);
+ const typeText = Components.interfaces.nsISearchEngine.DATA_TEXT;
+ if (searchService)
+ searchService.addEngine(engineURL, typeText, iconURL);
}
// property of nsIClassInfo
nsSidebar.prototype.flags = nsIClassInfo.DOM_OBJECT;
// property of nsIClassInfo
nsSidebar.prototype.classDescription = "Sidebar";
Index: browser/installer/removed-files.in
===================================================================
RCS file: /cvsroot/mozilla/browser/installer/removed-files.in,v
retrieving revision 1.10
diff -u -p -8 -r1.10 removed-files.in
--- browser/installer/removed-files.in 26 Feb 2006 18:25:18 -0000 1.10
+++ browser/installer/removed-files.in 17 Mar 2006 07:08:46 -0000
@@ -18,16 +18,28 @@ defaults/profile/extensions/{972ce4c6-7e
defaults/profile/extensions/Extensions.rdf
defaults/profile/extensions/installed-extensions.txt
defaults/profile/extensions/
defaults/profile/US/
extensions/{641d8d09-7dda-4850-8228-ac0ab65e2ac9}/install.rdf
extensions/{641d8d09-7dda-4850-8228-ac0ab65e2ac9}/
searchplugins/dictionary.src
searchplugins/dictionary.png
+searchplugins/amazondotcom.src
+searchplugins/amazondotcom.png
+searchplugins/creativecommons.src
+searchplugins/creativecommons.png
+searchplugins/answers.src
+searchplugins/answers.png
+searchplugins/eBay.src
+searchplugins/eBay.gif
+searchplugins/google.src
+searchplugins/google.gif
+searchplugins/yahoo.src
+searchplugins/yahoo.gif
searchplugins/
components/component.reg
components/compreg.dat
components/xpti.dat
components/xptitemp.dat
components/nsBackgroundUpdateService.js
#ifndef XP_MACOSX
components/autocomplete.xpt
Index: browser/installer/unix/packages-static
===================================================================
RCS file: /cvsroot/mozilla/browser/installer/unix/packages-static,v
retrieving revision 1.63
diff -u -p -8 -r1.63 packages-static
--- browser/installer/unix/packages-static 27 Jan 2006 22:52:29 -0000 1.63
+++ browser/installer/unix/packages-static 17 Mar 2006 07:08:46 -0000
@@ -53,16 +53,17 @@ bin/xpicleanup
bin/components/accessibility.xpt
bin/components/accessibility-atk.xpt
bin/components/appshell.xpt
bin/components/appstartup.xpt
bin/components/autocomplete.xpt
bin/components/autoconfig.xpt
bin/components/bookmarks.xpt
bin/components/browsercompsbase.xpt
+bin/components/browsersearch.xpt
bin/components/caps.xpt
bin/components/chardet.xpt
bin/components/chrome.xpt
bin/components/commandhandler.xpt
bin/components/commandlines.xpt
bin/components/composer.xpt
bin/components/content_base.xpt
bin/components/content_htmldoc.xpt
@@ -173,16 +174,17 @@ bin/components/xremoteservice.xpt
bin/components/xulapp.xpt
bin/components/xuldoc.xpt
bin/components/xultmpl.xpt
bin/components/shellservice.xpt
; JavaScript components
bin/components/nsBrowserContentHandler.js
bin/components/nsBrowserGlue.js
bin/components/nsSetDefaultBrowser.js
+bin/components/nsSearchService.js
bin/components/jsconsole-clhandler.js
bin/components/nsCloseAllWindows.js
bin/components/nsDictionary.js
bin/components/nsFilePicker.js
bin/components/nsHelperAppDlg.js
bin/components/nsInterfaceInfoToIDL.js
; bin/components/nsProgressDialog.js not needed for firefox
bin/components/nsProxyAutoConfig.js
Index: browser/installer/windows/packages-static
===================================================================
RCS file: /cvsroot/mozilla/browser/installer/windows/packages-static,v
retrieving revision 1.68
diff -u -p -8 -r1.68 packages-static
--- browser/installer/windows/packages-static 2 Feb 2006 20:56:10 -0000 1.68
+++ browser/installer/windows/packages-static 17 Mar 2006 07:08:46 -0000
@@ -57,16 +57,17 @@ bin\AccessibleMarshal.dll
bin\components\accessibility.xpt
bin\components\accessibility-msaa.xpt
bin\components\appshell.xpt
bin\components\appstartup.xpt
bin\components\autocomplete.xpt
bin\components\autoconfig.xpt
bin\components\bookmarks.xpt
bin\components\browsercompsbase.xpt
+bin\components\browsersearch.xpt
bin\components\caps.xpt
bin\components\chardet.xpt
bin\components\chrome.xpt
bin\components\commandhandler.xpt
bin\components\commandlines.xpt
bin\components\composer.xpt
bin\components\content_base.xpt
bin\components\content_html.xpt
@@ -189,16 +190,17 @@ bin\components\xultmpl.xpt
; JavaScript components
bin\components\nsBrowserContentHandler.js
bin\components\nsBrowserGlue.js
bin\components\nsSetDefaultBrowser.js
bin\components\nsCloseAllWindows.js
bin\components\nsDictionary.js
bin\components\nsHelperAppDlg.js
bin\components\nsProxyAutoConfig.js
+bin\components\nsSearchService.js
bin\components\nsSidebar.js
bin\components\nsXmlRpcClient.js
bin\components\nsExtensionManager.js
bin\components\nsUpdateService.js
bin\components\nsPostUpdateWin.js
bin\components\pluginGlue.js
bin\components\extensions.xpt
bin\components\update.xpt
Index: browser/locales/Makefile.in
===================================================================
RCS file: /cvsroot/mozilla/browser/locales/Makefile.in,v
retrieving revision 1.36
diff -u -p -8 -r1.36 Makefile.in
--- browser/locales/Makefile.in 16 Jan 2006 15:02:36 -0000 1.36
+++ browser/locales/Makefile.in 17 Mar 2006 07:08:46 -0000
@@ -120,20 +120,20 @@ install:: $(addprefix $(LOCALE_SRCDIR)/p
$(SYSINSTALL) $(IFLAGS1) $^ $(DESTDIR)$(mozappdir)/defaults/profile
install:: $(addprefix $(LOCALE_SRCDIR)/profile/chrome/,$(PROFILE_CHROME))
$(SYSINSTALL) $(IFLAGS1) $^ $(DESTDIR)$(mozappdir)/defaults/profile/chrome
SEARCH_PLUGINS = $(shell cat $(LOCALE_SRCDIR)/searchplugins/list.txt)
SEARCH_PLUGIN_PREFIX = $(addprefix $(LOCALE_SRCDIR)/searchplugins/,$(SEARCH_PLUGINS))
-libs:: $(addsuffix .src,$(SEARCH_PLUGIN_PREFIX)) $(foreach base,$(SEARCH_PLUGIN_PREFIX),$(wildcard $(base).gif)$(wildcard $(base).png))
+libs:: $(addsuffix .xml,$(SEARCH_PLUGIN_PREFIX)) $(foreach base,$(SEARCH_PLUGIN_PREFIX),$(wildcard $(base).gif)$(wildcard $(base).png))
$(INSTALL) $^ $(FINAL_TARGET)/searchplugins
-install:: $(addsuffix .src,$(SEARCH_PLUGIN_PREFIX)) $(foreach base,$(SEARCH_PLUGIN_PREFIX),$(wildcard $(base).gif)$(wildcard $(base).png))
+install:: $(addsuffix .xml,$(SEARCH_PLUGIN_PREFIX)) $(foreach base,$(SEARCH_PLUGIN_PREFIX),$(wildcard $(base).gif)$(wildcard $(base).png))
$(SYSINSTALL) $(IFLAGS1) $^ $(DESTDIR)$(mozappdir)/searchplugins
libs-%:
@$(MAKE) -C ../../toolkit/locales libs-$*
@$(MAKE) -C ../../extensions/reporter/locales libs AB_CD=$* XPI_NAME=locale-$*
@$(MAKE) libs AB_CD=$* XPI_NAME=locale-$* PREF_DIR=defaults/pref
ifdef MOZ_BRANDING_DIRECTORY
@$(MAKE) -C $(DEPTH)/$(MOZ_BRANDING_DIRECTORY)/locales AB_CD=$* XPI_NAME=locale-$*
Index: browser/locales/jar.mn
===================================================================
RCS file: /cvsroot/mozilla/browser/locales/jar.mn,v
retrieving revision 1.33
diff -u -p -8 -r1.33 jar.mn
--- browser/locales/jar.mn 10 Mar 2006 17:36:38 -0000 1.33
+++ browser/locales/jar.mn 17 Mar 2006 07:08:46 -0000
@@ -13,18 +13,17 @@
locale/browser/openLocation.properties (%chrome/browser/openLocation.properties)
locale/browser/page-drawer.dtd (%chrome/browser/page-drawer.dtd)
* locale/browser/pageInfo.dtd (%chrome/browser/pageInfo.dtd)
locale/browser/pageInfo.properties (%chrome/browser/pageInfo.properties)
locale/browser/pageReport.dtd (%chrome/browser/pageReport.dtd)
locale/browser/pageReportFirstTime.dtd (%chrome/browser/pageReportFirstTime.dtd)
* locale/browser/safeMode.dtd (%chrome/browser/safeMode.dtd)
locale/browser/sanitize.dtd (%chrome/browser/sanitize.dtd)
- locale/browser/searchbar.properties (%chrome/browser/searchbar.properties)
-* locale/browser/searchDialog.dtd (%chrome/browser/searchDialog.dtd)
+ locale/browser/search.properties (%chrome/browser/search.properties)
locale/browser/setDesktopBackground.dtd (%chrome/browser/setDesktopBackground.dtd)
locale/browser/shellservice.properties (%chrome/browser/shellservice.properties)
#ifdef MOZ_PLACES
locale/browser/places/places.dtd (%chrome/browser/places/places.dtd)
locale/browser/places/bookmarkProperties.dtd (%chrome/browser/places/bookmarkProperties.dtd)
locale/browser/places/bookmarkProperties.properties (%chrome/browser/places/bookmarkProperties.properties)
locale/browser/places/places.properties (%chrome/browser/places/places.properties)
locale/browser/places/default_places.html (%chrome/browser/places/default_places.html)
Index: browser/locales/en-US/chrome/browser/browser.properties
===================================================================
RCS file: /cvsroot/mozilla/browser/locales/en-US/chrome/browser/browser.properties,v
retrieving revision 1.22
diff -u -p -8 -r1.22 browser.properties
--- browser/locales/en-US/chrome/browser/browser.properties 16 Jan 2006 22:51:48 -0000 1.22
+++ browser/locales/en-US/chrome/browser/browser.properties 17 Mar 2006 07:08:46 -0000
@@ -24,17 +24,17 @@ nothingAvailable=(Nothing Available)
# Localization Note: Use 'true' or 'false' to control the pref:theme to
# show the English description or not
# for example, in Japanese build, instead of showing English description
# set the following value to false so it won't show up.
showskinsdescription=true
# context menu strings
-searchText=Search Web for "%S"
+contextMenuSearchText=Search %S for "%S"
blockImages=Block Images from %S
SavePageTitle=Save Web Page
SaveImageTitle=Save Picture
SaveLinkTitle=Save As
DefaultSaveFileName=index
WebPageCompleteFilter=Web Page, complete
Index: browser/locales/en-US/chrome/browser/search.properties
===================================================================
RCS file: browser/locales/en-US/chrome/browser/search.properties
diff -N browser/locales/en-US/chrome/browser/search.properties
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ browser/locales/en-US/chrome/browser/search.properties 17 Mar 2006 07:08:46 -0000
@@ -0,0 +1,15 @@
+searchtip=Search %S
+cmd_addEngine=Add Engines...
+cmd_addEngine_accesskey=A
+cmd_clearHistory=Clear Search History
+cmd_clearHistory_accesskey=C
+cmd_editList=Edit this list...
+cmd_editListAccesskey=E
+error_loading_engine_title=Download Error
+error_loading_engine_msg=%S could not download the search plugin from:\n%S\n\nPlease try again or contact the author.
+remove_engine_title=Remove Engine?
+remove_engine_msg=If you remove '%S' you will not be able to search using it from the Search Box any more. Are you sure you want to remove it?
+edit_name_title=Edit Name
+edit_name_msg=Enter a new Name:
+edit_alias_title=Edit Alias
+edit_alias_msg=Enter a new Alias:
Index: browser/locales/en-US/chrome/browser/searchDialog.dtd
===================================================================
RCS file: browser/locales/en-US/chrome/browser/searchDialog.dtd
diff -N browser/locales/en-US/chrome/browser/searchDialog.dtd
--- browser/locales/en-US/chrome/browser/searchDialog.dtd 29 Aug 2005 02:10:58 -0000 1.2
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,46 +0,0 @@
-
-
-
-
-
-
-
-
-
-
Index: browser/locales/en-US/chrome/browser/searchbar.properties
===================================================================
RCS file: browser/locales/en-US/chrome/browser/searchbar.properties
diff -N browser/locales/en-US/chrome/browser/searchbar.properties
--- browser/locales/en-US/chrome/browser/searchbar.properties 28 Jul 2005 21:02:02 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,5 +0,0 @@
-cmd_addEngine = Add Engines...
-cmd_addEngine_accesskey = A
-cmd_clearHistory = Clear Search History
-cmd_clearHistory_accesskey = S
-searchtip = Search %S
Index: browser/locales/en-US/chrome/browser/sidebar/sidebar.properties
===================================================================
RCS file: /cvsroot/mozilla/browser/locales/en-US/chrome/browser/sidebar/sidebar.properties,v
retrieving revision 1.2
diff -u -p -8 -r1.2 sidebar.properties
--- browser/locales/en-US/chrome/browser/sidebar/sidebar.properties 12 Jul 2004 17:15:09 -0000 1.2
+++ browser/locales/en-US/chrome/browser/sidebar/sidebar.properties 17 Mar 2006 07:08:47 -0000
@@ -1,2 +1,2 @@
addEngineConfirmTitle=Add Search Engine
-addEngineConfirmMessage=Add the following search engine to the Search Bar?##Name: %title%#Search Category: %category%#Source: %url%
+addEngineConfirmMessage=Add the following search engine to the Search Bar?##Name: %title%#Source: %url%
Index: browser/locales/en-US/chrome/browser-region/region.properties
===================================================================
RCS file: /cvsroot/mozilla/browser/locales/en-US/chrome/browser-region/region.properties,v
retrieving revision 1.10
diff -u -p -8 -r1.10 region.properties
--- browser/locales/en-US/chrome/browser-region/region.properties 3 Oct 2005 16:34:48 -0000 1.10
+++ browser/locales/en-US/chrome/browser-region/region.properties 17 Mar 2006 07:08:47 -0000
@@ -5,24 +5,24 @@ fallbackDefaultSearchURL=http://www.goog
releaseNotesURL=http://www.mozilla.org/products/firefox/releases/%S.html
# firefox.js
browser.startup.homepage=http://start.mozilla.org/firefox
browser.throbber.url=http://www.mozilla.org/products/firefox/central.html
browser.search.defaulturl=http://www.google.com/search?lr=&ie=UTF-8&oe=UTF-8&q=
+# Search engine order (order displayed in the search bar dropdown)s
browser.search.order.1=Google
browser.search.order.2=Yahoo
#config.js
startup.homepage_override_url=http://www.mozilla.org/products/firefox/releases/whatsnew/
-# search-panel.properties
-defaultSearchURL=http://www.google.com/search?hl=en&lr=&ie=UTF-8&oe=UTF-8&q=
+# Default search engine
browser.search.defaultenginename=Google
# update notifications: new update page
update_notifications.provider.0.datasource=
searchEnginesURL=http://www.mozilla.org/products/firefox/add-engines.html
feedLiveBookmarkInfoURL=http://www.mozilla.org/products/firefox/live-bookmarks
Index: browser/locales/en-US/searchplugins/amazondotcom.png
===================================================================
RCS file: browser/locales/en-US/searchplugins/amazondotcom.png
diff -N browser/locales/en-US/searchplugins/amazondotcom.png
Binary files /tmp/cvssX09eH and /dev/null differ
Index: browser/locales/en-US/searchplugins/amazondotcom.src
===================================================================
RCS file: browser/locales/en-US/searchplugins/amazondotcom.src
diff -N browser/locales/en-US/searchplugins/amazondotcom.src
--- browser/locales/en-US/searchplugins/amazondotcom.src 1 Nov 2005 11:25:16 -0000 1.4
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,26 +0,0 @@
-# Search Plug-in for Amazon.com (http://www.amazon.com)
-# by Paul Millar created: 18 January 2003
-# updated by Rafael Ebron
-
-
-
-
-
-
-
-
-
-
-
-
Index: browser/locales/en-US/searchplugins/amazondotcom.xml
===================================================================
RCS file: browser/locales/en-US/searchplugins/amazondotcom.xml
diff -N browser/locales/en-US/searchplugins/amazondotcom.xml
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ browser/locales/en-US/searchplugins/amazondotcom.xml 17 Mar 2006 07:08:49 -0000
@@ -0,0 +1,12 @@
+
+Amazon.com
+Amazon.com Search
+ISO-8859-1
+data:image/x-icon;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAAsQAAALEAGtI711AAAAB3RJTUUH0wESEi0MqTATXwAAAjVJREFUeJyFUlGLElEU/mbVHd2aaaRgWGyJgmXRINiXfJCeRgaiLEiKgYXoRQrqRejNH7D1uNBDPvbWtGxvS64IG2IIQQhxScpYMpt1l1qdptVVZ+z2oM6qu9KBC4dzv/Od73z3AmPROmjeVlWVKopCRVGkHMdRURSpoig0lUrRcfxI6LoelWV5GwCddOLx+PEklmVej0QiI80Oh4OyLHuE5Fgl/aJ9gsEgzefzm4SQzVgs9n8VqqqO7EwIsUGEkEscx9kEsizbd85BEo3eenzzRkRstTsfAVwRBOH+EP/DSb4x4wVN0wq5XE7MZDKz5XIZlUoFtVoNu7u7NkaWZaTTaWZEQV8qDYfDKBaLkwZOVkAI8UuS9GkwiWVZNBr7sLZeo1V6hb/GFrxGwW6s84twzYbgGBRM0/yZzWZtQCKRQGhuD80PT0DbdUzxF9DmA2jzAbiNIjztHUzvvT+UIoqi7TLHcVTX9QeWZVLLMikh5Nzwf2h9USlNgtIk6NSAoNlsYjgXBOG50+liAGCe3/72ayOGP28f9fZ2ewEAv89GYRMEAgGboNvtYjBtf0PB9BsZJz8/Q7dR7d3Xeia75+/0XsGyTEqNrzC/p9HVSzCr7w4N+7GGOr+IE6GnOH3+KgCgo2XhAeCak+DU16PUWL0Mr1EYfdO+027/PZxaWIKJmY4kSaX1lysXnat+HARXMOM5wzA0iSP/etDILixhp9aGz+djAEDTtLt8aflFt1GFcG2NAYB/rN8dqx12fbIAAAAASUVORK5CYII=
+
+
+
+
+
+
+
Index: browser/locales/en-US/searchplugins/answers.png
===================================================================
RCS file: browser/locales/en-US/searchplugins/answers.png
diff -N browser/locales/en-US/searchplugins/answers.png
Binary files /tmp/cvsOmY6ja and /dev/null differ
Index: browser/locales/en-US/searchplugins/answers.src
===================================================================
RCS file: browser/locales/en-US/searchplugins/answers.src
diff -N browser/locales/en-US/searchplugins/answers.src
--- browser/locales/en-US/searchplugins/answers.src 1 Nov 2005 11:25:16 -0000 1.6
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,17 +0,0 @@
-# Firefox Answers.com Sherlock Plugin by ben@mozilla.org
-# 4/6/2005
-
-
-
-
-
-
-
-
Index: browser/locales/en-US/searchplugins/answers.xml
===================================================================
RCS file: browser/locales/en-US/searchplugins/answers.xml
diff -N browser/locales/en-US/searchplugins/answers.xml
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ browser/locales/en-US/searchplugins/answers.xml 17 Mar 2006 07:08:49 -0000
@@ -0,0 +1,10 @@
+
+Answers.com
+Dictionary Search on Answers.com
+UTF-8
+data:image/x-icon;base64,AAABAAEAEBAAAAEAIABoBAAAFgAAACgAAAAQAAAAIAAAAAEAIAAAAAAAAAAAABMLAAATCwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA////K////4f////E////5f///+n////P////mv///0EAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD///8E////fv///+//////////////////////7NnP/+LFtv/////+////of///xYAAAAAAAAAAAAAAAD///8D////lf////////////j0//bi1v/OlXf/tGU9/6FCEv/OmH3////////////////D////FgAAAAAAAAAA////avPm4P/evaz/8NbI//7r3//23M3/xYRi/5kzAP/Df1z//u/l//749P/v4dn/+PPw/////6j///8B////GP///+W/f1//smM7//bczf/+69///uvf/9ytlP+ZMwD/5se3/+/f1//AgmP/nj0N/927qv/////+////QP///2z/////8NvQ/8WCYP/+69///uvf//7r3/+7ckz/pUkb/9m1ov+ePQ3/okUW/8+fh//38O3//////////5r///+t//////7y6v/Cflv/58Cr//DRwP/mwKv/okQU/8ODYv/cuqj/yZN4//Tq5f/+9e///vDn///////////Q////yf/////+7+b/05yA/65ZLv+9dVD/sF40/5kzAP/kvKb//vTu//Tr5v/7+Pb//vfz//707f//////////6f///8X//////vDm/+K4ov/KjGz//ure/8uNbf+jRBX/+OTX/+3b0v+jSBr/pk0h/717Wv/Wrpr//Pn4/////+b///+i//////7z7f/02Mj/wn5b//vl2P+uWS7/vXhU//v49//48u//1q6a/717Wv+oUSb/tWxH//jz8P/////K////V///////+/j//ure/8aFZP/fs5v/oEAQ/9q1o/+zaEL/1ayX//718P/+9/P/+PHu//jz8P//////////h////wr////O///////38v/YpYr/tGQ7/6ZLHf/06eX/s2dB/549Df/x49z//vDn//7x6f//////////8////yoAAAAA////R/////v/////7dXI/5kzAP+7cUv//vHp/+vYzv+bNwX/vHlY//38/P///////////////30AAAAAAAAAAAAAAAD///9n////+/z5+P++e1n/3LGc//7w5//++PT/0KKL/8OIa//9/Pv//////////5X///8GAAAAAAAAAAAAAAAAAAAAAP///0n////K///////////////////////////+/v7/////5v///2z///8CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA////Cv///1f///+g////xP///8n///+r////bP///xoAAAAAAAAAAAAAAAAAAAAA+B////AH///AA///wAH//4AB//+AAP//AAD//wAA//8AAP//AAD//4AA//+AAf//wAP//+AD///wD////D///w==
+
+
+
+
+
Index: browser/locales/en-US/searchplugins/creativecommons.png
===================================================================
RCS file: browser/locales/en-US/searchplugins/creativecommons.png
diff -N browser/locales/en-US/searchplugins/creativecommons.png
Binary files /tmp/cvsQ3AwpD and /dev/null differ
Index: browser/locales/en-US/searchplugins/creativecommons.src
===================================================================
RCS file: browser/locales/en-US/searchplugins/creativecommons.src
diff -N browser/locales/en-US/searchplugins/creativecommons.src
--- browser/locales/en-US/searchplugins/creativecommons.src 1 Nov 2005 11:25:16 -0000 1.5
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,38 +0,0 @@
-#
-# Mozilla/Netscape 6+ MyCroft Plugin for search.creativecommons.org for Mike Linksvayer #495.
-# Created by Ben Snider on April 1, 2004.
-# E-Mail: stupergenius@columbus.rr.com.
-#
-# Updated by Matt Haughey on August 26, 2004.
-# E-Mail: matt@creativecommons.org
-#
-
-
-
-
-
-
-
-
-
-
-
Index: browser/locales/en-US/searchplugins/creativecommons.xml
===================================================================
RCS file: browser/locales/en-US/searchplugins/creativecommons.xml
diff -N browser/locales/en-US/searchplugins/creativecommons.xml
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ browser/locales/en-US/searchplugins/creativecommons.xml 17 Mar 2006 07:08:49 -0000
@@ -0,0 +1,10 @@
+
+Creative Commons
+Find photos, movies, music, and text to rip, sample, mash, and share.
+utf-8
+data:image/x-icon;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAABGdBTUEAANbY1E9YMgAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAA2UExURf///wAAAD8/P+/v7y8vL19fX9/f37+/vw8PD8/Pz09PT5+fn4+Pj6+vr29vbx8fH39/f////3TGU44AAAASdFJOU///////////////////////AOK/vxIAAACWSURBVHjaNI8LEsQgCEMJIvi3vf9lN3bbN6MD0USUm3QFaVNYc7kBuvLZ0xG8oLkQV1iiYBjyktFE+tk+FCEGl3oFT0aSQBaoVDAmAyWkmOCitVfHTvV4BEsWxqyleE+PYLQAi5b9WJShPnh7MnQytDP1IxmfvZXq22dkTkpZ4/TT/qPfiX/dqoXJz+dItE0tx6l/AgwA0e4FeJjn5bsAAAAASUVORK5CYII=
+
+
+
+
+
Index: browser/locales/en-US/searchplugins/dictionary.src
===================================================================
RCS file: browser/locales/en-US/searchplugins/dictionary.src
diff -N browser/locales/en-US/searchplugins/dictionary.src
--- browser/locales/en-US/searchplugins/dictionary.src 23 Feb 2005 09:31:28 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,29 +0,0 @@
-# Mozilla/Dictionary.com plug-in by fissure@netscape.net
-# Updated by rebron@meer.net on 11 August 2004
-
-
-
-
-
-
-
-
-
-
Index: browser/locales/en-US/searchplugins/eBay.gif
===================================================================
RCS file: browser/locales/en-US/searchplugins/eBay.gif
diff -N browser/locales/en-US/searchplugins/eBay.gif
Binary files /tmp/cvsQj5z3k and /dev/null differ
Index: browser/locales/en-US/searchplugins/eBay.src
===================================================================
RCS file: browser/locales/en-US/searchplugins/eBay.src
diff -N browser/locales/en-US/searchplugins/eBay.src
--- browser/locales/en-US/searchplugins/eBay.src 1 Nov 2005 11:25:16 -0000 1.4
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,37 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-"
-resultListEnd = ""
-resultItemStart='