fix for bug #389003: sometimes favicons in url results are blank, need to use

the favicon service.

r=mano
This commit is contained in:
sspitzer@mozilla.org 2007-07-21 13:05:27 -07:00
parent e0ae845915
commit daca981d3e
5 changed files with 26 additions and 8 deletions

View File

@ -986,7 +986,6 @@ statusbarpanel#statusbar-display {
/* ----- AUTOCOMPLETE ----- */
.autocomplete-treebody::-moz-tree-image(favicon, treecolAutoCompleteValue) {
list-style-image: url("chrome://mozapps/skin/places/defaultFavicon.png");
width: 16px;
height: 16px;
}

View File

@ -987,7 +987,6 @@ statusbarpanel#statusbar-display {
/* ::::: autocomplete ::::: */
.autocomplete-treebody::-moz-tree-image(favicon, treecolAutoCompleteValue) {
list-style-image: url("chrome://mozapps/skin/places/defaultFavicon.png");
width: 16px;
height: 16px;
}

View File

@ -294,7 +294,7 @@ nsFaviconService::SetFaviconUrlForPageInternal(nsIURI* aPage, nsIURI* aFavicon,
// now link our entry with the history service
nsNavHistory* historyService = nsNavHistory::GetHistoryService();
NS_ENSURE_TRUE(historyService, NS_ERROR_NO_INTERFACE);
NS_ENSURE_TRUE(historyService, NS_ERROR_OUT_OF_MEMORY);
PRInt64 pageId;
rv = historyService->GetUrlIdFor(aPage, &pageId, PR_TRUE);

View File

@ -106,6 +106,7 @@
#include "mozIStorageFunction.h"
#include "mozStorageCID.h"
#include "mozStorageHelper.h"
#include "nsFaviconService.h"
#define NS_AUTOCOMPLETESIMPLERESULT_CONTRACTID \
"@mozilla.org/autocomplete/simple-result;1"
@ -361,7 +362,6 @@ nsNavHistory::StopSearch()
return NS_OK;
}
// nsNavHistory::AutoCompleteTypedSearch
//
// Called when there is no search string. This happens when you press
@ -390,6 +390,9 @@ nsresult nsNavHistory::AutoCompleteTypedSearch(
if (! urls.Init(500))
return NS_ERROR_OUT_OF_MEMORY;
nsFaviconService* faviconService = nsFaviconService::GetFaviconService();
NS_ENSURE_TRUE(faviconService, NS_ERROR_OUT_OF_MEMORY);
PRInt32 dummy;
PRInt32 count = 0;
PRBool hasMore = PR_FALSE;
@ -402,7 +405,11 @@ nsresult nsNavHistory::AutoCompleteTypedSearch(
if (! urls.Get(entryURL, &dummy)) {
// new item
rv = result->AppendMatch(entryURL, entryTitle, entryImage, NS_LITERAL_STRING("favicon"));
nsCAutoString faviconSpec;
faviconService->GetFaviconSpecForIconString(
NS_ConvertUTF16toUTF8(entryImage), faviconSpec);
rv = result->AppendMatch(entryURL, entryTitle,
NS_ConvertUTF8toUTF16(faviconSpec), NS_LITERAL_STRING("favicon"));
NS_ENSURE_SUCCESS(rv, rv);
urls.Put(entryURL, 1);
@ -497,19 +504,32 @@ nsNavHistory::AutoCompleteFullHistorySearch(const nsAString& aSearchString,
AUTOCOMPLETE_MATCHES_SCHEME_PENALTY, &matches);
}
nsFaviconService* faviconService = nsFaviconService::GetFaviconService();
NS_ENSURE_TRUE(faviconService, NS_ERROR_OUT_OF_MEMORY);
// fill into result
if (matches.Length() > 0) {
// sort according to priorities
AutoCompleteResultComparator comparator(this);
matches.Sort(comparator);
rv = aResult->AppendMatch(matches[0].url, matches[0].title, matches[0].image, NS_LITERAL_STRING("favicon"));
nsCAutoString faviconSpec;
faviconService->GetFaviconSpecForIconString(
NS_ConvertUTF16toUTF8(matches[0].image), faviconSpec);
rv = aResult->AppendMatch(matches[0].url, matches[0].title,
NS_ConvertUTF8toUTF16(faviconSpec),
NS_LITERAL_STRING("favicon"));
NS_ENSURE_SUCCESS(rv, rv);
for (i = 1; i < matches.Length(); i ++) {
// only add ones that are NOT the same as the previous one. It's possible
// to get duplicates from the queries.
if (!matches[i].url.Equals(matches[i-1].url)) {
rv = aResult->AppendMatch(matches[i].url, matches[i].title, matches[i].image, NS_LITERAL_STRING("favicon"));
faviconService->GetFaviconSpecForIconString(
NS_ConvertUTF16toUTF8(matches[i].image), faviconSpec);
rv = aResult->AppendMatch(matches[i].url, matches[i].title,
NS_ConvertUTF8toUTF16(faviconSpec),
NS_LITERAL_STRING("favicon"));
NS_ENSURE_SUCCESS(rv, rv);
}
}

View File

@ -127,7 +127,7 @@ NS_IMETHODIMP
nsNavHistoryResultNode::GetIcon(nsIURI** aURI)
{
nsFaviconService* faviconService = nsFaviconService::GetFaviconService();
NS_ENSURE_TRUE(faviconService, NS_ERROR_NO_INTERFACE);
NS_ENSURE_TRUE(faviconService, NS_ERROR_OUT_OF_MEMORY);
if (mFaviconURI.IsEmpty()) {
*aURI = nsnull;
return NS_OK;