зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1702240. Change nsDocShell's notification of keyword-search pass a string rather than an engine. r=Standard8
Differential Revision: https://phabricator.services.mozilla.com/D130336
This commit is contained in:
Родитель
a62c197b64
Коммит
5264bfd45a
|
@ -1124,7 +1124,9 @@ BrowserGlue.prototype = {
|
|||
// URI that it's been asked to load into a keyword search.
|
||||
let engine = null;
|
||||
try {
|
||||
engine = subject.QueryInterface(Ci.nsISearchEngine);
|
||||
engine = Services.search.getEngineByName(
|
||||
subject.QueryInterface(Ci.nsISupportsString).data
|
||||
);
|
||||
} catch (ex) {
|
||||
Cu.reportError(ex);
|
||||
}
|
||||
|
|
|
@ -146,6 +146,7 @@
|
|||
#include "nsIScriptSecurityManager.h"
|
||||
#include "nsIScrollableFrame.h"
|
||||
#include "nsIScrollObserver.h"
|
||||
#include "nsISupportsPrimitives.h"
|
||||
#include "nsISecureBrowserUI.h"
|
||||
#include "nsISeekableStream.h"
|
||||
#include "nsISelectionDisplay.h"
|
||||
|
@ -203,7 +204,6 @@
|
|||
#include "nsEscape.h"
|
||||
#include "nsFocusManager.h"
|
||||
#include "nsGlobalWindow.h"
|
||||
#include "nsISearchService.h"
|
||||
#include "nsJSEnvironment.h"
|
||||
#include "nsNetCID.h"
|
||||
#include "nsNetUtil.h"
|
||||
|
@ -13231,20 +13231,19 @@ void nsDocShell::MaybeNotifyKeywordSearchLoading(const nsString& aProvider,
|
|||
if (aProvider.IsEmpty()) {
|
||||
return;
|
||||
}
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsISupportsString> isupportsString =
|
||||
do_CreateInstance(NS_SUPPORTS_STRING_CONTRACTID, &rv);
|
||||
NS_ENSURE_SUCCESS_VOID(rv);
|
||||
|
||||
nsCOMPtr<nsISearchService> searchSvc =
|
||||
do_GetService("@mozilla.org/browser/search-service;1");
|
||||
if (searchSvc) {
|
||||
nsCOMPtr<nsISearchEngine> searchEngine;
|
||||
searchSvc->GetEngineByName(aProvider, getter_AddRefs(searchEngine));
|
||||
if (searchEngine) {
|
||||
nsCOMPtr<nsIObserverService> obsSvc = services::GetObserverService();
|
||||
if (obsSvc) {
|
||||
// Note that "keyword-search" refers to a search via the url
|
||||
// bar, not a bookmarks keyword search.
|
||||
obsSvc->NotifyObservers(searchEngine, "keyword-search", aKeyword.get());
|
||||
}
|
||||
}
|
||||
rv = isupportsString->SetData(aProvider);
|
||||
NS_ENSURE_SUCCESS_VOID(rv);
|
||||
|
||||
nsCOMPtr<nsIObserverService> obsSvc = services::GetObserverService();
|
||||
if (obsSvc) {
|
||||
// Note that "keyword-search" refers to a search via the url
|
||||
// bar, not a bookmarks keyword search.
|
||||
obsSvc->NotifyObservers(isupportsString, "keyword-search", aKeyword.get());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -46,9 +46,9 @@ add_task(async function() {
|
|||
|
||||
let [subject, data] = await TestUtils.topicObserved("keyword-search");
|
||||
|
||||
let engine = Services.search.defaultEngine;
|
||||
Assert.ok(engine, "Have default search engine.");
|
||||
Assert.equal(engine, subject, "Notification subject is engine.");
|
||||
let engine = subject.QueryInterface(Ci.nsISupportsString).data;
|
||||
|
||||
Assert.equal(engine, kSearchEngineID, "Should be the search engine id");
|
||||
Assert.equal(data, "firefox", "Notification data is search term.");
|
||||
|
||||
gBrowser.removeTab(tab);
|
||||
|
|
Загрузка…
Ссылка в новой задаче