Bug 1057166 - move FHR reporting out of docshell and fix test to work in e10s, r=bz

--HG--
extra : rebase_source : d5b9122803f306ab08deb85b953bbc7129e182f0
This commit is contained in:
Gijs Kruitbosch 2014-09-11 14:50:55 +01:00
parent 9df36d6225
commit aff56ac9f2
13 changed files with 222 additions and 87 deletions

View File

@ -694,7 +694,7 @@ function gKeywordURIFixup({ target: browser, data: fixupInfo }) {
// whether the original input would be vaguely interpretable as a URL,
// so figure that out first.
let alternativeURI = deserializeURI(fixupInfo.fixedURI);
if (!fixupInfo.fixupUsedKeyword || !alternativeURI || !alternativeURI.host) {
if (!fixupInfo.keywordProviderName || !alternativeURI || !alternativeURI.host) {
return;
}

View File

@ -300,20 +300,16 @@ nsDefaultURIFixup::GetFixupURIInfo(const nsACString& aStringURI, uint32_t aFixup
ioService->GetProtocolHandler(scheme.get(), getter_AddRefs(ourHandler));
extHandler = do_GetService(NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX"default");
nsCOMPtr<nsIURI> uri;
if (ourHandler != extHandler || !PossiblyHostPortUrl(uriString)) {
// Just try to create an URL out of it
rv = NS_NewURI(getter_AddRefs(uri), uriString, nullptr);
if (NS_SUCCEEDED(rv)) {
info->mFixedURI = uri;
}
rv = NS_NewURI(getter_AddRefs(info->mFixedURI), uriString, nullptr);
if (!uri && rv != NS_ERROR_MALFORMED_URI) {
if (!info->mFixedURI && rv != NS_ERROR_MALFORMED_URI) {
return rv;
}
}
if (uri && ourHandler == extHandler && sFixupKeywords &&
if (info->mFixedURI && ourHandler == extHandler && sFixupKeywords &&
(aFixupFlags & FIXUP_FLAG_FIX_SCHEME_TYPOS)) {
nsCOMPtr<nsIExternalProtocolService> extProtService =
do_GetService(NS_EXTERNALPROTOCOLSERVICE_CONTRACTID);
@ -328,18 +324,17 @@ nsDefaultURIFixup::GetFixupURIInfo(const nsACString& aStringURI, uint32_t aFixup
// It's more likely the user wants to search, and so we
// chuck this over to their preferred search provider instead:
if (!handlerExists) {
nsresult rv = KeywordToURI(uriString, aPostData, getter_AddRefs(uri));
if (NS_SUCCEEDED(rv) && uri) {
info->mFixupUsedKeyword = true;
}
TryKeywordFixupForURIInfo(uriString, info, aPostData);
}
}
}
if (uri) {
if (aFixupFlags & FIXUP_FLAGS_MAKE_ALTERNATE_URI)
info->mFixupCreatedAlternateURI = MakeAlternateURI(uri);
info->mPreferredURI = uri;
if (info->mFixedURI) {
if (!info->mPreferredURI) {
if (aFixupFlags & FIXUP_FLAGS_MAKE_ALTERNATE_URI)
info->mFixupCreatedAlternateURI = MakeAlternateURI(info->mFixedURI);
info->mPreferredURI = info->mFixedURI;
}
return NS_OK;
}
@ -374,9 +369,10 @@ nsDefaultURIFixup::GetFixupURIInfo(const nsACString& aStringURI, uint32_t aFixup
// Test whether keywords need to be fixed up
if (sFixupKeywords && (aFixupFlags & FIXUP_FLAG_ALLOW_KEYWORD_LOOKUP) &&
!inputHadDuffProtocol) {
KeywordURIFixup(uriString, info, aPostData);
if (info->mPreferredURI)
if (NS_SUCCEEDED(KeywordURIFixup(uriString, info, aPostData)) &&
info->mPreferredURI) {
return NS_OK;
}
}
// Did the caller want us to try an alternative URI?
@ -415,12 +411,7 @@ nsDefaultURIFixup::GetFixupURIInfo(const nsACString& aStringURI, uint32_t aFixup
// If we still haven't been able to construct a valid URI, try to force a
// keyword match. This catches search strings with '.' or ':' in them.
if (sFixupKeywords && (aFixupFlags & FIXUP_FLAG_ALLOW_KEYWORD_LOOKUP)) {
rv = KeywordToURI(aStringURI, aPostData, getter_AddRefs(info->mPreferredURI));
if (NS_SUCCEEDED(rv) && info->mPreferredURI)
{
info->mFixupUsedKeyword = true;
return NS_OK;
}
rv = TryKeywordFixupForURIInfo(aStringURI, info, aPostData);
}
return rv;
@ -428,9 +419,11 @@ nsDefaultURIFixup::GetFixupURIInfo(const nsACString& aStringURI, uint32_t aFixup
NS_IMETHODIMP nsDefaultURIFixup::KeywordToURI(const nsACString& aKeyword,
nsIInputStream **aPostData,
nsIURI **aURI)
nsIURIFixupInfo **aInfo)
{
*aURI = nullptr;
nsRefPtr<nsDefaultURIFixupInfo> info = new nsDefaultURIFixupInfo(aKeyword);
NS_ADDREF(*aInfo = info);
if (aPostData) {
*aPostData = nullptr;
}
@ -451,10 +444,14 @@ NS_IMETHODIMP nsDefaultURIFixup::KeywordToURI(const nsACString& aKeyword,
ipc::OptionalInputStreamParams postData;
ipc::OptionalURIParams uri;
if (!contentChild->SendKeywordToURI(keyword, &postData, &uri)) {
nsAutoString providerName;
if (!contentChild->SendKeywordToURI(keyword, &providerName, &postData, &uri)) {
return NS_ERROR_FAILURE;
}
CopyUTF8toUTF16(keyword, info->mKeywordAsSent);
info->mKeywordProviderName = providerName;
if (aPostData) {
nsTArray<ipc::FileDescriptor> fds;
nsCOMPtr<nsIInputStream> temp = DeserializeInputStream(postData, fds);
@ -464,7 +461,7 @@ NS_IMETHODIMP nsDefaultURIFixup::KeywordToURI(const nsACString& aKeyword,
}
nsCOMPtr<nsIURI> temp = DeserializeURI(uri);
temp.forget(aURI);
info->mPreferredURI = temp.forget();
return NS_OK;
}
@ -486,7 +483,8 @@ NS_IMETHODIMP nsDefaultURIFixup::KeywordToURI(const nsACString& aKeyword,
responseType.Assign(mozKeywordSearch);
}
defaultEngine->GetSubmission(NS_ConvertUTF8toUTF16(keyword),
NS_ConvertUTF8toUTF16 keywordW(keyword);
defaultEngine->GetSubmission(keywordW,
responseType,
NS_LITERAL_STRING("keyword"),
getter_AddRefs(submission));
@ -504,21 +502,9 @@ NS_IMETHODIMP nsDefaultURIFixup::KeywordToURI(const nsACString& aKeyword,
return NS_ERROR_FAILURE;
}
// This notification is meant for Firefox Health Report so it
// can increment counts from the search engine. The assumption
// here is that this keyword/submission will eventually result
// in a search. Since we only generate a URI here, there is the
// possibility we'll increment the counter without actually
// incurring a search. A robust solution would involve currying
// the search engine's name through various function calls.
nsCOMPtr<nsIObserverService> obsSvc = mozilla::services::GetObserverService();
if (obsSvc) {
// Note that "keyword-search" refers to a search via the url
// bar, not a bookmarks keyword search.
obsSvc->NotifyObservers(defaultEngine, "keyword-search", NS_ConvertUTF8toUTF16(keyword).get());
}
return submission->GetUri(aURI);
defaultEngine->GetName(info->mKeywordProviderName);
info->mKeywordAsSent = keywordW;
return submission->GetUri(getter_AddRefs(info->mPreferredURI));
}
}
}
@ -528,6 +514,22 @@ NS_IMETHODIMP nsDefaultURIFixup::KeywordToURI(const nsACString& aKeyword,
return NS_ERROR_NOT_AVAILABLE;
}
// Helper to deal with passing around uri fixup stuff
nsresult
nsDefaultURIFixup::TryKeywordFixupForURIInfo(const nsACString & aURIString,
nsDefaultURIFixupInfo* aFixupInfo,
nsIInputStream **aPostData)
{
nsCOMPtr<nsIURIFixupInfo> keywordInfo;
nsresult rv = KeywordToURI(aURIString, aPostData, getter_AddRefs(keywordInfo));
if (NS_SUCCEEDED(rv)) {
keywordInfo->GetKeywordProviderName(aFixupInfo->mKeywordProviderName);
keywordInfo->GetKeywordAsSent(aFixupInfo->mKeywordAsSent);
keywordInfo->GetPreferredURI(getter_AddRefs(aFixupInfo->mPreferredURI));
}
return rv;
}
bool nsDefaultURIFixup::MakeAlternateURI(nsIURI *aURI)
{
if (!Preferences::GetRootBranch())
@ -923,9 +925,10 @@ bool nsDefaultURIFixup::PossiblyByteExpandedFileName(const nsAString& aIn)
return false;
}
void nsDefaultURIFixup::KeywordURIFixup(const nsACString & aURIString,
nsDefaultURIFixupInfo* aFixupInfo,
nsIInputStream **aPostData)
nsresult
nsDefaultURIFixup::KeywordURIFixup(const nsACString & aURIString,
nsDefaultURIFixupInfo* aFixupInfo,
nsIInputStream **aPostData)
{
// These are keyword formatted strings
// "what is mozilla"
@ -1023,7 +1026,6 @@ void nsDefaultURIFixup::KeywordURIFixup(const nsACString & aURIString,
looksLikeIpv6 = false;
}
nsresult rv;
nsAutoCString asciiHost;
nsAutoCString host;
@ -1041,7 +1043,7 @@ void nsDefaultURIFixup::KeywordURIFixup(const nsACString & aURIString,
((foundDots + foundDigits == pos - 1) ||
(foundColons == 1 && firstColonLoc > lastDotLoc &&
foundDots + foundDigits + foundColons == pos - 1))) {
return;
return NS_OK;
}
uint32_t posWithNoTrailingSlash = pos;
@ -1054,15 +1056,16 @@ void nsDefaultURIFixup::KeywordURIFixup(const nsACString & aURIString,
((foundDots + foundDigits == posWithNoTrailingSlash) ||
(foundColons == 1 && firstColonLoc > lastDotLoc &&
foundDots + foundDigits + foundColons == posWithNoTrailingSlash))) {
return;
return NS_OK;
}
// If there are only colons and only hexadecimal characters ([a-z][0-9])
// enclosed in [], then don't do a keyword lookup
if (looksLikeIpv6) {
return;
return NS_OK;
}
nsresult rv = NS_OK;
// We do keyword lookups if a space or quote preceded the dot, colon
// or question mark (or if the latter were not found)
// or when the host is the same as asciiHost and there are no
@ -1073,11 +1076,7 @@ void nsDefaultURIFixup::KeywordURIFixup(const nsACString & aURIString,
(isValidAsciiHost && isValidHost && !hasAsciiAlpha &&
host.EqualsIgnoreCase(asciiHost.get()))) {
rv = KeywordToURI(aFixupInfo->mOriginalInput, aPostData,
getter_AddRefs(aFixupInfo->mPreferredURI));
if (NS_SUCCEEDED(rv) && aFixupInfo->mPreferredURI) {
aFixupInfo->mFixupUsedKeyword = true;
}
rv = TryKeywordFixupForURIInfo(aFixupInfo->mOriginalInput, aFixupInfo, aPostData);
}
// ... or if there is no question mark or colon, and there is either no
// dot, or exactly 1 and it is the first or last character of the input:
@ -1086,17 +1085,14 @@ void nsDefaultURIFixup::KeywordURIFixup(const nsACString & aURIString,
firstColonLoc == uint32_t(kNotFound) && firstQMarkLoc == uint32_t(kNotFound)) {
if (isValidAsciiHost && IsDomainWhitelisted(asciiHost, firstDotLoc)) {
return;
return NS_OK;
}
// If we get here, we don't have a valid URI, or we did but the
// host is not whitelisted, so we do a keyword search *anyway*:
rv = KeywordToURI(aFixupInfo->mOriginalInput, aPostData,
getter_AddRefs(aFixupInfo->mPreferredURI));
if (NS_SUCCEEDED(rv) && aFixupInfo->mPreferredURI) {
aFixupInfo->mFixupUsedKeyword = true;
}
rv = TryKeywordFixupForURIInfo(aFixupInfo->mOriginalInput, aFixupInfo, aPostData);
}
return rv;
}
bool nsDefaultURIFixup::IsDomainWhitelisted(const nsAutoCString aAsciiHost,
@ -1134,7 +1130,6 @@ nsresult NS_NewURIFixup(nsIURIFixup **aURIFixup)
NS_IMPL_ISUPPORTS(nsDefaultURIFixupInfo, nsIURIFixupInfo)
nsDefaultURIFixupInfo::nsDefaultURIFixupInfo(const nsACString& aOriginalInput):
mFixupUsedKeyword(false),
mFixupChangedProtocol(false),
mFixupCreatedAlternateURI(false)
{
@ -1178,9 +1173,16 @@ nsDefaultURIFixupInfo::GetFixedURI(nsIURI** aFixedURI)
}
NS_IMETHODIMP
nsDefaultURIFixupInfo::GetFixupUsedKeyword(bool* aOut)
nsDefaultURIFixupInfo::GetKeywordProviderName(nsAString& aOut)
{
*aOut = mFixupUsedKeyword;
aOut = mKeywordProviderName;
return NS_OK;
}
NS_IMETHODIMP
nsDefaultURIFixupInfo::GetKeywordAsSent(nsAString& aOut)
{
aOut = mKeywordAsSent;
return NS_OK;
}

View File

@ -30,9 +30,12 @@ private:
nsresult FixupURIProtocol(const nsACString& aIn,
nsDefaultURIFixupInfo* aFixupInfo,
nsIURI** aURI);
void KeywordURIFixup(const nsACString &aStringURI,
nsDefaultURIFixupInfo* aFixupInfo,
nsIInputStream** aPostData);
nsresult KeywordURIFixup(const nsACString &aStringURI,
nsDefaultURIFixupInfo* aFixupInfo,
nsIInputStream** aPostData);
nsresult TryKeywordFixupForURIInfo(const nsACString &aStringURI,
nsDefaultURIFixupInfo* aFixupInfo,
nsIInputStream** aPostData);
bool PossiblyByteExpandedFileName(const nsAString& aIn);
bool PossiblyHostPortUrl(const nsACString& aUrl);
bool MakeAlternateURI(nsIURI *aURI);
@ -58,9 +61,10 @@ private:
nsCOMPtr<nsISupports> mConsumer;
nsCOMPtr<nsIURI> mPreferredURI;
nsCOMPtr<nsIURI> mFixedURI;
bool mFixupUsedKeyword;
bool mFixupChangedProtocol;
bool mFixupCreatedAlternateURI;
nsString mKeywordProviderName;
nsString mKeywordAsSent;
nsAutoCString mOriginalInput;
};
#endif

View File

@ -201,6 +201,10 @@
#include "mozilla/dom/ScriptSettings.h"
#include "mozilla/dom/URLSearchParams.h"
#ifdef MOZ_TOOLKIT_SEARCH
#include "nsIBrowserSearchService.h"
#endif
static NS_DEFINE_CID(kAppShellCID, NS_APPSHELL_CID);
#if defined(DEBUG_bryner) || defined(DEBUG_chb)
@ -4583,6 +4587,7 @@ nsDocShell::LoadURIWithBase(const char16_t * aURI,
aLoadFlags &= ~LOAD_FLAGS_ALLOW_THIRD_PARTY_FIXUP;
}
nsCOMPtr<nsIURIFixupInfo> fixupInfo;
if (sURIFixup) {
// Call the fixup object. This will clobber the rv from NS_NewURI
// above, but that's fine with us. Note that we need to do this even
@ -4596,7 +4601,6 @@ nsDocShell::LoadURIWithBase(const char16_t * aURI,
fixupFlags |= nsIURIFixup::FIXUP_FLAG_FIX_SCHEME_TYPOS;
}
nsCOMPtr<nsIInputStream> fixupStream;
nsCOMPtr<nsIURIFixupInfo> fixupInfo;
rv = sURIFixup->GetFixupURIInfo(uriString, fixupFlags,
getter_AddRefs(fixupStream),
getter_AddRefs(fixupInfo));
@ -4607,7 +4611,7 @@ nsDocShell::LoadURIWithBase(const char16_t * aURI,
}
if (fixupStream) {
// CreateFixupURI only returns a post data stream if it succeeded
// GetFixupURIInfo only returns a post data stream if it succeeded
// and changed the URI, in which case we should override the
// passed-in post data.
postStream = fixupStream;
@ -4666,6 +4670,13 @@ nsDocShell::LoadURIWithBase(const char16_t * aURI,
loadInfo->SetHeadersStream(aHeaderStream);
loadInfo->SetBaseURI(aBaseURI);
if (fixupInfo) {
nsAutoString searchProvider, keyword;
fixupInfo->GetKeywordProviderName(searchProvider);
fixupInfo->GetKeywordAsSent(keyword);
MaybeNotifyKeywordSearchLoading(searchProvider, keyword);
}
rv = LoadURI(uri, loadInfo, extraFlags, true);
// Save URI string in case it's needed later when
@ -7382,6 +7393,7 @@ nsDocShell::EndPageLoad(nsIWebProgress * aProgress,
//
// First try keyword fixup
//
nsAutoString keywordProviderName, keywordAsSent;
if (aStatus == NS_ERROR_UNKNOWN_HOST && mAllowKeywordFixup) {
bool keywordsEnabled =
Preferences::GetBool("keyword.enabled", false);
@ -7412,11 +7424,12 @@ nsDocShell::EndPageLoad(nsIWebProgress * aProgress,
}
if (keywordsEnabled && (kNotFound == dotLoc)) {
nsCOMPtr<nsIURIFixupInfo> info;
// only send non-qualified hosts to the keyword server
if (!mOriginalUriString.IsEmpty()) {
sURIFixup->KeywordToURI(mOriginalUriString,
getter_AddRefs(newPostData),
getter_AddRefs(newURI));
getter_AddRefs(info));
}
else {
//
@ -7438,13 +7451,19 @@ nsDocShell::EndPageLoad(nsIWebProgress * aProgress,
NS_SUCCEEDED(idnSrv->ConvertACEtoUTF8(host, utf8Host))) {
sURIFixup->KeywordToURI(utf8Host,
getter_AddRefs(newPostData),
getter_AddRefs(newURI));
getter_AddRefs(info));
} else {
sURIFixup->KeywordToURI(host,
getter_AddRefs(newPostData),
getter_AddRefs(newURI));
getter_AddRefs(info));
}
}
info->GetPreferredURI(getter_AddRefs(newURI));
if (newURI) {
info->GetKeywordAsSent(keywordAsSent);
info->GetKeywordProviderName(keywordProviderName);
}
} // end keywordsEnabled
}
@ -7477,6 +7496,8 @@ nsDocShell::EndPageLoad(nsIWebProgress * aProgress,
if (doCreateAlternate) {
newURI = nullptr;
newPostData = nullptr;
keywordProviderName.Truncate();
keywordAsSent.Truncate();
sURIFixup->CreateFixupURI(oldSpec,
nsIURIFixup::FIXUP_FLAGS_MAKE_ALTERNATE_URI,
getter_AddRefs(newPostData),
@ -7497,6 +7518,10 @@ nsDocShell::EndPageLoad(nsIWebProgress * aProgress,
newURI->GetSpec(newSpec);
NS_ConvertUTF8toUTF16 newSpecW(newSpec);
// This notification is meant for Firefox Health Report so it
// can increment counts from the search engine
MaybeNotifyKeywordSearchLoading(keywordProviderName, keywordAsSent);
return LoadURI(newSpecW.get(), // URI string
LOAD_FLAGS_NONE, // Load flags
nullptr, // Referring URI
@ -13508,3 +13533,36 @@ nsDocShell::GetURLSearchParams()
{
return mURLSearchParams;
}
void
nsDocShell::MaybeNotifyKeywordSearchLoading(const nsString &aProvider,
const nsString &aKeyword) {
if (aProvider.IsEmpty()) {
return;
}
if (XRE_GetProcessType() == GeckoProcessType_Content) {
dom::ContentChild* contentChild = dom::ContentChild::GetSingleton();
if (contentChild) {
contentChild->SendNotifyKeywordSearchLoading(aProvider, aKeyword);
}
return;
}
#ifdef MOZ_TOOLKIT_SEARCH
nsCOMPtr<nsIBrowserSearchService> 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 = mozilla::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());
}
}
}
#endif
}

View File

@ -978,6 +978,9 @@ private:
nsIDocShellTreeItem* aOriginalRequestor,
nsIDocShellTreeItem** _retval);
// Notify consumers of a search being loaded through the observer service:
void MaybeNotifyKeywordSearchLoading(const nsString &aProvider, const nsString &aKeyword);
#ifdef DEBUG
// We're counting the number of |nsDocShells| to help find leaks
static unsigned long gNumberOfDocShells;

View File

@ -12,7 +12,7 @@ interface nsIInputStream;
/**
* Interface indicating what we found/corrected when fixing up a URI
*/
[scriptable, uuid(62aac1e0-3da8-4920-bd1b-a54fc2e2eb24)]
[scriptable, uuid(4819f183-b532-4932-ac09-b309cd853be7)]
interface nsIURIFixupInfo : nsISupports
{
/**
@ -36,9 +36,16 @@ interface nsIURIFixupInfo : nsISupports
readonly attribute nsIURI fixedURI;
/**
* Whether the preferred option ended up using a keyword search.
* The name of the keyword search provider used to provide a keyword search;
* empty string if no keyword search was done.
*/
readonly attribute boolean fixupUsedKeyword;
readonly attribute AString keywordProviderName;
/**
* The keyword as used for the search (post trimming etc.)
* empty string if no keyword search was done.
*/
readonly attribute AString keywordAsSent;
/**
* Whether we changed the protocol instead of using one from the input as-is.
@ -63,7 +70,7 @@ interface nsIURIFixupInfo : nsISupports
/**
* Interface implemented by objects capable of fixing up strings into URIs
*/
[scriptable, uuid(49298f2b-3630-4874-aecc-522300a7fead)]
[scriptable, uuid(d2a78abe-e678-4103-9bcc-dd1377460c44)]
interface nsIURIFixup : nsISupports
{
/** No fixup flags. */
@ -146,7 +153,7 @@ interface nsIURIFixup : nsISupports
* @throws NS_ERROR_FAILURE if the resulting URI requires submission of POST
* data and aPostData is null.
*/
nsIURI keywordToURI(in AUTF8String aKeyword,
[optional] out nsIInputStream aPostData);
nsIURIFixupInfo keywordToURI(in AUTF8String aKeyword,
[optional] out nsIInputStream aPostData);
};

View File

@ -95,7 +95,6 @@ skip-if = e10s # Bug ?????? - event handler checks event.target is the content d
[browser_onbeforeunload_navigation.js]
skip-if = e10s
[browser_search_notification.js]
skip-if = e10s
[browser_timelineMarkers-01.js]
[browser_timelineMarkers-02.js]
skip-if = e10s

View File

@ -4,6 +4,27 @@
function test() {
waitForExplicitFinish();
const kSearchEngineID = "test_urifixup_search_engine";
const kSearchEngineURL = "http://localhost/?search={searchTerms}";
Services.search.addEngineWithDetails(kSearchEngineID, "", "", "", "get",
kSearchEngineURL);
let oldDefaultEngine = Services.search.defaultEngine;
Services.search.defaultEngine = Services.search.getEngineByName(kSearchEngineID);
let selectedName = Services.search.defaultEngine.name;
is(selectedName, kSearchEngineID, "Check fake search engine is selected");
registerCleanupFunction(function() {
if (oldDefaultEngine) {
Services.search.defaultEngine = oldDefaultEngine;
}
let engine = Services.search.getEngineByName(kSearchEngineID);
if (engine) {
Services.search.removeEngine(engine);
}
});
let tab = gBrowser.addTab();
gBrowser.selectedTab = tab;

View File

@ -530,7 +530,7 @@ function run_test() {
// Check booleans on input:
let couldDoKeywordLookup = flags & urifixup.FIXUP_FLAG_ALLOW_KEYWORD_LOOKUP;
do_check_eq(info.fixupUsedKeyword, couldDoKeywordLookup && expectKeywordLookup);
do_check_eq(!!info.keywordProviderName, couldDoKeywordLookup && expectKeywordLookup);
do_check_eq(info.fixupChangedProtocol, expectProtocolChange);
do_check_eq(info.fixupCreatedAlternateURI, makeAlternativeURI && alternativeURI != null);

View File

@ -185,6 +185,10 @@ using namespace mozilla::system;
#include "mozilla/Sandbox.h"
#endif
#ifdef MOZ_TOOLKIT_SEARCH
#include "nsIBrowserSearchService.h"
#endif
static NS_DEFINE_CID(kCClipboardCID, NS_CLIPBOARD_CID);
static const char* sClipboardTextFlavors[] = { kUnicodeMime };
@ -3805,7 +3809,9 @@ ContentParent::RecvSetFakeVolumeState(const nsString& fsName, const int32_t& fsS
}
bool
ContentParent::RecvKeywordToURI(const nsCString& aKeyword, OptionalInputStreamParams* aPostData,
ContentParent::RecvKeywordToURI(const nsCString& aKeyword,
nsString* aProviderName,
OptionalInputStreamParams* aPostData,
OptionalURIParams* aURI)
{
nsCOMPtr<nsIURIFixup> fixup = do_GetService(NS_URIFIXUP_CONTRACTID);
@ -3814,20 +3820,45 @@ ContentParent::RecvKeywordToURI(const nsCString& aKeyword, OptionalInputStreamPa
}
nsCOMPtr<nsIInputStream> postData;
nsCOMPtr<nsIURI> uri;
nsCOMPtr<nsIURIFixupInfo> info;
if (NS_FAILED(fixup->KeywordToURI(aKeyword, getter_AddRefs(postData),
getter_AddRefs(uri)))) {
getter_AddRefs(info)))) {
return true;
}
info->GetKeywordProviderName(*aProviderName);
nsTArray<mozilla::ipc::FileDescriptor> fds;
SerializeInputStream(postData, *aPostData, fds);
MOZ_ASSERT(fds.IsEmpty());
nsCOMPtr<nsIURI> uri;
info->GetPreferredURI(getter_AddRefs(uri));
SerializeURI(uri, *aURI);
return true;
}
bool
ContentParent::RecvNotifyKeywordSearchLoading(const nsString &aProvider,
const nsString &aKeyword) {
#ifdef MOZ_TOOLKIT_SEARCH
nsCOMPtr<nsIBrowserSearchService> 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 = mozilla::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());
}
}
}
#endif
return true;
}
bool
ContentParent::ShouldContinueFromReplyTimeout()
{

View File

@ -631,9 +631,14 @@ private:
virtual bool RecvSetFakeVolumeState(const nsString& fsName, const int32_t& fsState) MOZ_OVERRIDE;
virtual bool RecvKeywordToURI(const nsCString& aKeyword, OptionalInputStreamParams* aPostData,
virtual bool RecvKeywordToURI(const nsCString& aKeyword,
nsString* aProviderName,
OptionalInputStreamParams* aPostData,
OptionalURIParams* aURI) MOZ_OVERRIDE;
virtual bool RecvNotifyKeywordSearchLoading(const nsString &aProvider,
const nsString &aKeyword) MOZ_OVERRIDE;
virtual void ProcessingError(Result what) MOZ_OVERRIDE;
virtual bool RecvAllocateLayerTreeId(uint64_t* aId) MOZ_OVERRIDE;

View File

@ -670,7 +670,9 @@ parent:
async SetFakeVolumeState(nsString fsName, int32_t fsState);
sync KeywordToURI(nsCString keyword)
returns (OptionalInputStreamParams postData, OptionalURIParams uri);
returns (nsString providerName, OptionalInputStreamParams postData, OptionalURIParams uri);
sync NotifyKeywordSearchLoading(nsString providerName, nsString keyword);
// Tell the compositor to allocate a layer tree id for nested remote mozbrowsers.
sync AllocateLayerTreeId()

View File

@ -126,6 +126,9 @@ DEFINES['BIN_SUFFIX'] = '"%s"' % CONFIG['BIN_SUFFIX']
if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('android', 'gtk2', 'gonk', 'qt'):
DEFINES['MOZ_ENABLE_FREETYPE'] = True
if CONFIG['MOZ_TOOLKIT_SEARCH']:
DEFINES['MOZ_TOOLKIT_SEARCH'] = True
for var in ('MOZ_PERMISSIONS', 'MOZ_CHILD_PERMISSIONS'):
if CONFIG[var]:
DEFINES[var] = True