From d3813da5968e7238c7f6a4e642bbb050bfbb2fcb Mon Sep 17 00:00:00 2001 From: "timeless%mozdev.org" Date: Tue, 21 Oct 2003 17:00:37 +0000 Subject: [PATCH] Bug 143687 Bring back site icons (favicons) in personal toolbar patch by mozilla-bugs@nogin.org r=varga sr=alecf git-svn-id: svn://10.0.0.236/trunk@148209 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/modules/libpref/src/init/all.js | 3 + .../resources/content/navigatorOverlay.xul | 12 ++++ .../bookmarks/src/nsBookmarksService.cpp | 55 +++++++++++-------- .../bookmarks/src/nsBookmarksService.h | 17 +++--- 4 files changed, 57 insertions(+), 30 deletions(-) diff --git a/mozilla/modules/libpref/src/init/all.js b/mozilla/modules/libpref/src/init/all.js index 4e20bc9c25b..fb425e0e8de 100644 --- a/mozilla/modules/libpref/src/init/all.js +++ b/mozilla/modules/libpref/src/init/all.js @@ -110,6 +110,9 @@ pref("browser.urlbar.matchOnlyTyped", false); pref("browser.chrome.site_icons", true); pref("browser.chrome.favicons", false); +// 0 = never, 1 = when in cache, 2 = always +pref("browser.chrome.load_toolbar_icons", 0); + pref("browser.chrome.toolbar_tips", true); // 0 = Pictures Only, 1 = Text Only, 2 = Pictures and Text pref("browser.chrome.toolbar_style", 2); diff --git a/mozilla/xpfe/browser/resources/content/navigatorOverlay.xul b/mozilla/xpfe/browser/resources/content/navigatorOverlay.xul index a48d01e4fa6..6ba797ed45f 100644 --- a/mozilla/xpfe/browser/resources/content/navigatorOverlay.xul +++ b/mozilla/xpfe/browser/resources/content/navigatorOverlay.xul @@ -227,6 +227,8 @@ @@ -236,6 +238,8 @@ @@ -243,6 +247,8 @@ @@ -273,6 +281,8 @@ @@ -287,6 +297,8 @@ diff --git a/mozilla/xpfe/components/bookmarks/src/nsBookmarksService.cpp b/mozilla/xpfe/components/bookmarks/src/nsBookmarksService.cpp index 60f7ef63c9c..5daf6f16202 100644 --- a/mozilla/xpfe/components/bookmarks/src/nsBookmarksService.cpp +++ b/mozilla/xpfe/components/bookmarks/src/nsBookmarksService.cpp @@ -1744,8 +1744,14 @@ nsBookmarksService::Init() nsCOMPtr prefServ(do_GetService(kPrefCID, &rv)); if (NS_SUCCEEDED(rv) && (prefServ)) { - // get browser icon pref - prefServ->GetBoolPref("browser.chrome.site_icons", &mBrowserIcons); + // get browser icon prefs + PRInt32 toolbarIcons = 0; + prefServ->GetIntPref("browser.chrome.load_toolbar_icons", &toolbarIcons); + if (toolbarIcons > 0) { + prefServ->GetBoolPref("browser.chrome.site_icons", &mBrowserIcons); + mAlwaysLoadIcons = (toolbarIcons > 1); + } else + mAlwaysLoadIcons = mBrowserIcons = PR_FALSE; // determine what the name of the Personal Toolbar Folder is... // first from user preference, then string bundle, then hard-coded default @@ -4178,10 +4184,13 @@ nsBookmarksService::ProcessCachedBookmarkIcon(nsIRDFResource* aSource, } } + PRBool forceLoad = mAlwaysLoadIcons; + // if no internal icon reference, try and synthesize a URL if (path.IsEmpty()) { const char *uri; + forceLoad = PR_FALSE; if (NS_FAILED(rv = aSource->GetValueConst( &uri ))) { return rv; @@ -4214,27 +4223,29 @@ nsBookmarksService::ProcessCachedBookmarkIcon(nsIRDFResource* aSource, path.Append("/favicon.ico"); } - // only return favicon reference if its in the cache - // (that is, never go out onto the net) - if (!mCacheSession) - { - return NS_RDF_NO_VALUE; + if (!forceLoad) { + // only return favicon reference if its in the cache + // (that is, never go out onto the net) + if (!mCacheSession) + { + return NS_RDF_NO_VALUE; + } + nsCOMPtr entry; + rv = mCacheSession->OpenCacheEntry(path.get(), nsICache::ACCESS_READ, + nsICache::NON_BLOCKING, getter_AddRefs(entry)); + if (NS_FAILED(rv) || (!entry)) + { + return NS_RDF_NO_VALUE; + } + if (entry) + { + PRUint32 expTime; + entry->GetExpirationTime(&expTime); + if (expTime != PR_UINT32_MAX) + entry->SetExpirationTime(PR_UINT32_MAX); + } + entry->Close(); } - nsCOMPtr entry; - rv = mCacheSession->OpenCacheEntry(path.get(), nsICache::ACCESS_READ, - nsICache::NON_BLOCKING, getter_AddRefs(entry)); - if (NS_FAILED(rv) || (!entry)) - { - return NS_RDF_NO_VALUE; - } - if (entry) - { - PRUint32 expTime; - entry->GetExpirationTime(&expTime); - if (expTime != PR_UINT32_MAX) - entry->SetExpirationTime(PR_UINT32_MAX); - } - entry->Close(); // ok, have a cached icon entry, so return the URL's associated favicon nsAutoString litStr; diff --git a/mozilla/xpfe/components/bookmarks/src/nsBookmarksService.h b/mozilla/xpfe/components/bookmarks/src/nsBookmarksService.h index c875015dc47..9fba9ce64f1 100644 --- a/mozilla/xpfe/components/bookmarks/src/nsBookmarksService.h +++ b/mozilla/xpfe/components/bookmarks/src/nsBookmarksService.h @@ -94,21 +94,22 @@ protected: PRInt32 mUpdateBatchNest; nsXPIDLString mPersonalToolbarName; nsXPIDLString mBookmarksRootName; - PRBool mDirty; - PRBool mBrowserIcons; - PRBool busySchedule; + PRPackedBool mDirty; + PRPackedBool mBrowserIcons; + PRPackedBool mAlwaysLoadIcons; + PRPackedBool busySchedule; // System Bookmark parsing -#if defined(XP_WIN) +#if defined(XP_MAC) || defined(XP_MACOSX) + PRPackedBool mIEFavoritesAvailable; + + nsresult ReadFavorites(); +#elif defined(XP_WIN) // @param aDirectory - Favorites Folder to import from. // @param aParentResource - Folder into which to place imported // Favorites. nsresult ParseFavoritesFolder(nsIFile* aDirectory, nsIRDFResource* aParentResource); -#elif defined(XP_MAC) || defined(XP_MACOSX) - PRBool mIEFavoritesAvailable; - - nsresult ReadFavorites(); #endif #if defined(XP_WIN) || defined(XP_MAC) || defined(XP_MACOSX)