From f509a34254a254348465dbe018c6ee9db081193e Mon Sep 17 00:00:00 2001 From: Eric Butler Date: Sun, 17 Dec 2006 19:17:36 +0000 Subject: Add search_link entry to _EphyEmbedIface 2006-12-17 Eric Butler * src/ephy-embed.h: Add search_link entry to _EphyEmbedIface * src/ephy-embed.c: Add ge-search-link signal * embed/mozilla/EphyBrowser.cs: Fire ge-search-link signal for opensearch tags --- embed/mozilla/EphyBrowser.cpp | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'embed/mozilla') diff --git a/embed/mozilla/EphyBrowser.cpp b/embed/mozilla/EphyBrowser.cpp index aba1645eb..a233279a3 100644 --- a/embed/mozilla/EphyBrowser.cpp +++ b/embed/mozilla/EphyBrowser.cpp @@ -221,6 +221,39 @@ EphyDOMLinkEventListener::HandleEvent (nsIDOMEvent* aDOMEvent) /* ok, we accept this as a valid favicon for this site */ g_signal_emit_by_name (mOwner->mEmbed, "ge_favicon", spec.get()); } + else if (g_ascii_strcasecmp (rel.get (), "search") == 0) + { + linkElement->GetAttribute (NS_LITERAL_STRING ("type"), value); + + nsCString cTypeVal; + NS_UTF16ToCString (value, NS_CSTRING_ENCODING_UTF8, cTypeVal); + + if (g_ascii_strcasecmp (cTypeVal.get (), + "application/opensearchdescription+xml") == 0) + { + rv = linkElement->GetAttribute (NS_LITERAL_STRING ("href"), value); + if (NS_FAILED (rv) || !value.Length()) return NS_ERROR_FAILURE; + + nsCString cLink; + NS_UTF16ToCString (value, NS_CSTRING_ENCODING_UTF8, cLink); + + nsCOMPtr docUri; + rv = GetDocURI (linkElement, getter_AddRefs (docUri)); + NS_ENSURE_TRUE (NS_SUCCEEDED (rv) && docUri, NS_ERROR_FAILURE); + + nsCString resolvedLink; + rv = docUri->Resolve (cLink, resolvedLink); + NS_ENSURE_SUCCESS (rv, NS_ERROR_FAILURE); + + linkElement->GetAttribute (NS_LITERAL_STRING ("title"), value); + + nsCString cTitle; + NS_UTF16ToCString (value, NS_CSTRING_ENCODING_UTF8, cTitle); + + g_signal_emit_by_name (mOwner->mEmbed, "ge_search_link", + cTypeVal.get(), cTitle.get(), resolvedLink.get()); + } + } else if (g_ascii_strcasecmp (rel.get (), "alternate") == 0) { linkElement->GetAttribute (NS_LITERAL_STRING ("type"), value); -- cgit v1.2.3