author | Marco Bonardo <mbonardo@mozilla.com> |
Thu, 16 Apr 2015 10:56:34 +0200 | |
changeset 239465 | 75afd4419cd3407fa32a9526475bcc50b8c84056 |
parent 239464 | 2f8060bb3f9417055bb2b701fde82ea02beb8918 |
child 239466 | a1eaa7d45f0c941547551cefedb11e8ac120e7fc |
push id | 28599 |
push user | ryanvm@gmail.com |
push date | Thu, 16 Apr 2015 20:10:43 +0000 |
treeherder | mozilla-central@701c4a82fc56 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | jaws |
bugs | 1094844 |
milestone | 40.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
--- a/browser/components/preferences/in-content/search.js +++ b/browser/components/preferences/in-content/search.js @@ -1,14 +1,17 @@ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ Components.utils.import("resource://gre/modules/XPCOMUtils.jsm"); -Components.utils.import("resource://gre/modules/PlacesUtils.jsm"); +XPCOMUtils.defineLazyModuleGetter(this, "PlacesUtils", + "resource://gre/modules/PlacesUtils.jsm"); +XPCOMUtils.defineLazyModuleGetter(this, "Task", + "resource://gre/modules/Task.jsm"); const ENGINE_FLAVOR = "text/x-moz-search-engine"; var gEngineView = null; var gSearchPane = { init: function () @@ -186,29 +189,23 @@ var gSearchPane = { let index = gEngineView.selectedIndex; gEngineView.rowCountChanged(index, -1); gEngineView.invalidate(); gEngineView.selection.select(Math.min(index, gEngineView.lastIndex)); gEngineView.ensureRowIsVisible(gEngineView.currentIndex); document.getElementById("engineList").focus(); }, - editKeyword: function(aEngine, aNewKeyword) { + editKeyword: Task.async(function* (aEngine, aNewKeyword) { if (aNewKeyword) { - let bduplicate = false; let eduplicate = false; let dupName = ""; - try { - let bmserv = - Components.classes["@mozilla.org/browser/nav-bookmarks-service;1"] - .getService(Components.interfaces.nsINavBookmarksService); - if (bmserv.getURIForKeyword(aNewKeyword)) - bduplicate = true; - } catch(ex) {} + // Check for duplicates in Places keywords. + let bduplicate = !!(yield PlacesUtils.keywords.fetch(aNewKeyword)); // Check for duplicates in changes we haven't committed yet let engines = gEngineView._engineStore.engines; for each (let engine in engines) { if (engine.alias == aNewKeyword && engine.name != aEngine.name) { eduplicate = true; dupName = engine.name; @@ -226,17 +223,17 @@ var gSearchPane = { Services.prompt.alert(window, dtitle, eduplicate ? emsg : bmsg); return false; } } gEngineView._engineStore.changeEngine(aEngine, "alias", aNewKeyword); gEngineView.invalidate(); return true; - }, + }), saveOneClickEnginesList: function () { let hiddenList = []; for (let engine of gEngineView._engineStore.engines) { if (!engine.shown) hiddenList.push(engine.name); } document.getElementById("browser.search.hiddenOneOffs").value = @@ -514,19 +511,19 @@ EngineView.prototype = { if (column.id == "engineShown") { this._engineStore.engines[index].shown = value == "true"; gEngineView.invalidate(); gSearchPane.saveOneClickEnginesList(); } }, setCellText: function(index, column, value) { if (column.id == "engineKeyword") { - if (!gSearchPane.editKeyword(this._engineStore.engines[index], value)) { - setTimeout(() => { + gSearchPane.editKeyword(this._engineStore.engines[index], value) + .then(valid => { + if (!valid) document.getElementById("engineList").startEditing(index, column); - }, 0); - } + }); } }, performAction: function(action) { }, performActionOnRow: function(action, index) { }, performActionOnCell: function(action, index, column) { } };
--- a/browser/components/preferences/search.js +++ b/browser/components/preferences/search.js @@ -1,14 +1,17 @@ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ Components.utils.import("resource://gre/modules/XPCOMUtils.jsm"); -Components.utils.import("resource://gre/modules/PlacesUtils.jsm"); +XPCOMUtils.defineLazyModuleGetter(this, "PlacesUtils", + "resource://gre/modules/PlacesUtils.jsm"); +XPCOMUtils.defineLazyModuleGetter(this, "Task", + "resource://gre/modules/Task.jsm"); const ENGINE_FLAVOR = "text/x-moz-search-engine"; var gEngineView = null; var gSearchPane = { init: function () @@ -118,29 +121,23 @@ var gSearchPane = { let index = gEngineView.selectedIndex; gEngineView.rowCountChanged(index, -1); gEngineView.invalidate(); gEngineView.selection.select(Math.min(index, gEngineView.lastIndex)); gEngineView.ensureRowIsVisible(gEngineView.currentIndex); document.getElementById("engineList").focus(); }, - editKeyword: function(aEngine, aNewKeyword) { + editKeyword: Task.async(function* (aEngine, aNewKeyword) { if (aNewKeyword) { - let bduplicate = false; let eduplicate = false; let dupName = ""; - try { - let bmserv = - Components.classes["@mozilla.org/browser/nav-bookmarks-service;1"] - .getService(Components.interfaces.nsINavBookmarksService); - if (bmserv.getURIForKeyword(aNewKeyword)) - bduplicate = true; - } catch(ex) {} + // Check for duplicates in Places keywords. + let bduplicate = !!(yield PlacesUtils.keywords.fetch(aNewKeyword)); // Check for duplicates in changes we haven't committed yet let engines = gEngineView._engineStore.engines; for each (let engine in engines) { if (engine.alias == aNewKeyword && engine.name != aEngine.name) { eduplicate = true; dupName = engine.name; @@ -158,17 +155,17 @@ var gSearchPane = { Services.prompt.alert(window, dtitle, eduplicate ? emsg : bmsg); return false; } } gEngineView._engineStore.changeEngine(aEngine, "alias", aNewKeyword); gEngineView.invalidate(); return true; - }, + }), saveOneClickEnginesList: function () { let hiddenList = []; for (let engine of gEngineView._engineStore.engines) { if (!engine.shown) hiddenList.push(engine.name); } document.getElementById("browser.search.hiddenOneOffs").value = @@ -529,19 +526,19 @@ EngineView.prototype = { if (column.id == "engineShown") { this._engineStore.engines[index].shown = value == "true"; gEngineView.invalidate(); gSearchPane.saveOneClickEnginesList(); } }, setCellText: function(index, column, value) { if (column.id == "engineKeyword") { - if (!gSearchPane.editKeyword(this._engineStore.engines[index], value)) { - setTimeout(() => { + gSearchPane.editKeyword(this._engineStore.engines[index], value) + .then(valid => { + if (!valid) document.getElementById("engineList").startEditing(index, column); - }, 0); - } + }); } }, performAction: function(action) { }, performActionOnRow: function(action, index) { }, performActionOnCell: function(action, index, column) { } };
--- a/browser/components/search/content/engineManager.js +++ b/browser/components/search/content/engineManager.js @@ -1,13 +1,18 @@ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +Components.utils.import("resource://gre/modules/XPCOMUtils.jsm"); Components.utils.import("resource://gre/modules/Services.jsm"); +XPCOMUtils.defineLazyModuleGetter(this, "PlacesUtils", + "resource://gre/modules/PlacesUtils.jsm"); +XPCOMUtils.defineLazyModuleGetter(this, "Task", + "resource://gre/modules/Task.jsm"); const Ci = Components.interfaces; const Cc = Components.classes; const ENGINE_FLAVOR = "text/x-moz-search-engine"; const BROWSER_SUGGEST_PREF = "browser.search.suggest.enabled"; @@ -100,38 +105,34 @@ var gEngineManagerDialog = { gEngineView.invalidate(); gEngineView.selection.select(newIndex); gEngineView.ensureRowIsVisible(newIndex); this.showRestoreDefaults(true); document.getElementById("engineList").focus(); }, - editKeyword: function engineManager_editKeyword() { + editKeyword: Task.async(function* () { var selectedEngine = gEngineView.selectedEngine; if (!selectedEngine) return; var alias = { value: selectedEngine.alias }; var strings = document.getElementById("engineManagerBundle"); var title = strings.getString("editTitle"); var msg = strings.getFormattedString("editMsg", [selectedEngine.name]); while (Services.prompt.prompt(window, title, msg, alias, null, {})) { var bduplicate = false; var eduplicate = false; var dupName = ""; if (alias.value != "") { - try { - let bmserv = Cc["@mozilla.org/browser/nav-bookmarks-service;1"]. - getService(Ci.nsINavBookmarksService); - if (bmserv.getURIForKeyword(alias.value)) - bduplicate = true; - } catch(ex) {} + // Check for duplicates in Places keywords. + bduplicate = !!(yield PlacesUtils.keywords.fetch(alias.value)); // Check for duplicates in changes we haven't committed yet let engines = gEngineView._engineStore.engines; for each (let engine in engines) { if (engine.alias == alias.value && engine.name != selectedEngine.name) { eduplicate = true; dupName = engine.name; @@ -149,17 +150,17 @@ var gEngineManagerDialog = { Services.prompt.alert(window, dtitle, eduplicate ? emsg : bmsg); } else { gEngineView._engineStore.changeEngine(selectedEngine, "alias", alias.value); gEngineView.invalidate(); break; } } - }, + }), onSelect: function engineManager_onSelect() { // Buttons only work if an engine is selected and it's not the last engine, // the latter is true when the selected is first and last at the same time. var lastSelected = (gEngineView.selectedIndex == gEngineView.lastIndex); var firstSelected = (gEngineView.selectedIndex == 0); var noSelection = (gEngineView.selectedIndex == -1);
--- a/browser/components/search/content/engineManager.xul +++ b/browser/components/search/content/engineManager.xul @@ -31,17 +31,17 @@ disabled="true"/> <command id="cmd_moveup" oncommand="gEngineManagerDialog.bump(1);" disabled="true"/> <command id="cmd_movedown" oncommand="gEngineManagerDialog.bump(-1);" disabled="true"/> <command id="cmd_editkeyword" - oncommand="gEngineManagerDialog.editKeyword();" + oncommand="gEngineManagerDialog.editKeyword().catch(Components.utils.reportError);" disabled="true"/> </commandset> <keyset id="engineManagerKeyset"> <key id="delete" keycode="VK_DELETE" command="cmd_remove"/> </keyset> <stringbundleset id="engineManagerBundleset">