Fix bug #108809. r=ben sr=hyatt
git-svn-id: svn://10.0.0.236/trunk@109451 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -67,3 +67,16 @@ outlinerbody:-moz-outliner-image(Name) {
|
||||
list-style-image: url("chrome://communicator/skin/bookmarks/bookmark-item-updated.gif") !important;
|
||||
}
|
||||
|
||||
.bookmark-item > .toolbarbutton-box > .toolbarbutton-icon
|
||||
{
|
||||
list-style-image: inherit;
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
}
|
||||
|
||||
.tree-cell-icon, .tree-cell-primary-icon {
|
||||
list-style-image: inherit;
|
||||
height: 16px;
|
||||
max-width: 32px; /* 32 pixel hack to get too-large favicons to show; fix when tree becomes outliner */
|
||||
max-height: 16px;
|
||||
}
|
||||
|
||||
@@ -194,7 +194,7 @@
|
||||
<binding id="toolbarbutton-left" extends="chrome://global/content/bindings/button.xml#buttonleft">
|
||||
<content>
|
||||
<xul:hbox align="center" flex="1">
|
||||
<xul:image class="toolbarbutton-left-icon" inherits="src,disabled"/>
|
||||
<xul:image class="toolbarbutton-left-icon" inherits="src=image,disabled"/>
|
||||
<xul:label class="toolbarbutton-left-text" inherits="value=label,crop"/>
|
||||
</xul:hbox>
|
||||
</content>
|
||||
@@ -203,7 +203,7 @@
|
||||
<binding id="toolbarbutton-top" extends="chrome://global/content/bindings/button.xml#buttontop">
|
||||
<content>
|
||||
<xul:vbox flex="1" align="center">
|
||||
<xul:image class="toolbarbutton-top-icon" inherits="src,disabled"/>
|
||||
<xul:image class="toolbarbutton-top-icon" inherits="src=image,disabled"/>
|
||||
<xul:label class="toolbarbutton-top-text" inherits="value=label,crop"/>
|
||||
</xul:vbox>
|
||||
</content>
|
||||
|
||||
@@ -228,3 +228,9 @@ menuitem[checked="true"][menuactive="true"]
|
||||
margin-left: -6px;
|
||||
list-style-image: url("chrome://global/skin/columnselect.gif");
|
||||
}
|
||||
|
||||
.menu-iconic-icon {
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
list-style-image: inherit;
|
||||
}
|
||||
|
||||
@@ -89,8 +89,6 @@ popup > menuitem[menuactive="true"]
|
||||
{
|
||||
color : inherit;
|
||||
margin : 0px 4px 0px 3px;
|
||||
width : 16px;
|
||||
list-style-image : inherit;
|
||||
}
|
||||
|
||||
.menubar-left
|
||||
@@ -243,4 +241,11 @@ menuitem[checked="true"][type="radio"][menuactive="true"]
|
||||
{
|
||||
margin-left: -4px;
|
||||
list-style-image: url("chrome://global/skin/columnselect.gif");
|
||||
}
|
||||
}
|
||||
|
||||
.menu-iconic-icon
|
||||
{
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
list-style-image: inherit;
|
||||
}
|
||||
|
||||
@@ -53,3 +53,16 @@
|
||||
list-style-image: url("chrome://communicator/skin/icons/loading.gif") !important;
|
||||
}
|
||||
|
||||
.bookmark-item > .toolbarbutton-box > .toolbarbutton-icon
|
||||
{
|
||||
list-style-image: inherit;
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
}
|
||||
|
||||
.tree-cell-icon, .tree-cell-primary-icon {
|
||||
list-style-image: inherit;
|
||||
height: 16px;
|
||||
max-width: 32px; /* 32 pixel hack to get too-large favicons to show; fix when tree becomes outliner */
|
||||
max-height: 16px;
|
||||
}
|
||||
|
||||
@@ -68,16 +68,17 @@ menuitem[menuactive="true"][disabled="true"] {
|
||||
padding-right: 14px;
|
||||
}
|
||||
|
||||
.menu-iconic-left {
|
||||
width: 16px;
|
||||
list-style-image: inherit;
|
||||
}
|
||||
|
||||
.menu-iconic-accel {
|
||||
margin-left: 4px;
|
||||
padding-right: 14px;
|
||||
}
|
||||
|
||||
.menu-iconic-icon {
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
list-style-image: inherit;
|
||||
}
|
||||
|
||||
/* ..... menu arrow box ..... */
|
||||
|
||||
.menu-right {
|
||||
|
||||
@@ -121,6 +121,19 @@ function UpdateBookmarksLastVisitedDate(event)
|
||||
}
|
||||
}
|
||||
|
||||
function HandleBookmarkIcon(iconURL, addFlag)
|
||||
{
|
||||
var url = _content.location.href;
|
||||
if (url) {
|
||||
// update URL with new icon reference
|
||||
if (!gBookmarksService)
|
||||
gBookmarksService = Components.classes["@mozilla.org/browser/bookmarks-service;1"]
|
||||
.getService(Components.interfaces.nsIBookmarksService);
|
||||
if (addFlag) gBookmarksService.UpdateBookmarkIcon(url, iconURL);
|
||||
else gBookmarksService.RemoveBookmarkIcon(url, iconURL);
|
||||
}
|
||||
}
|
||||
|
||||
function UpdateInternetSearchResults(event)
|
||||
{
|
||||
// XXX This somehow causes a big leak, back to the old way
|
||||
|
||||
@@ -189,8 +189,8 @@ Contributor(s): ______________________________________. -->
|
||||
ondraggesture="PageProxyDragGesture(event);"/>
|
||||
<image id="page-proxy-favicon" validate="never"
|
||||
ondraggesture="PageProxyDragGesture(event);"
|
||||
onload="this.parentNode.selectedIndex = 1; event.stopPropagation(); event.preventBubble();"
|
||||
onerror="gBrowser.addToMissedIconCache(this.src);"/>
|
||||
onload="this.parentNode.selectedIndex = 1; event.stopPropagation(); event.preventBubble(); HandleBookmarkIcon(this.src, true);"
|
||||
onerror="gBrowser.addToMissedIconCache(this.src); HandleBookmarkIcon(this.src, false);"/>
|
||||
</deck>
|
||||
<menupopup id="ubhist-popup" class="autocomplete-history-popup"
|
||||
popupalign="topleft" popupanchor="bottomleft"
|
||||
@@ -312,6 +312,8 @@ Contributor(s): ______________________________________. -->
|
||||
|
||||
<rule parent="hbox">
|
||||
<toolbarbutton class="bookmark-item" uri="rdf:*" editable="true"
|
||||
image="rdf:http://home.netscape.com/NC-rdf#Icon"
|
||||
validate="never"
|
||||
status="rdf:http://home.netscape.com/WEB-rdf#status"
|
||||
rdf:type="http://home.netscape.com/NC-rdf#Bookmark"
|
||||
tooltiptext="rdf:http://home.netscape.com/NC-rdf#URL"
|
||||
@@ -349,6 +351,8 @@ Contributor(s): ______________________________________. -->
|
||||
<rule>
|
||||
<menupopup>
|
||||
<menuitem class="menuitem-iconic bookmark-item" uri="rdf:*"
|
||||
src="rdf:http://home.netscape.com/NC-rdf#Icon"
|
||||
validate="never"
|
||||
status="rdf:http://home.netscape.com/WEB-rdf#status"
|
||||
label="rdf:http://home.netscape.com/NC-rdf#Name"/>
|
||||
</menupopup>
|
||||
|
||||
@@ -329,7 +329,9 @@
|
||||
</rule>
|
||||
<rule>
|
||||
<menupopup>
|
||||
<menuitem class="menuitem-iconic bookmark-item" uri="rdf:*"
|
||||
<menuitem class="menuitem-iconic bookmark-item" uri="rdf:*"
|
||||
src="rdf:http://home.netscape.com/NC-rdf#Icon"
|
||||
validate="never"
|
||||
label="rdf:http://home.netscape.com/NC-rdf#Name"
|
||||
status="rdf:http://home.netscape.com/WEB-rdf#status"/>
|
||||
</menupopup>
|
||||
|
||||
@@ -166,7 +166,15 @@ nsBrowserStatusHandler.prototype =
|
||||
|
||||
onLinkIconAvailable : function(aHref) {
|
||||
if (gProxyFavIcon && pref.getBoolPref("browser.chrome.site_icons"))
|
||||
{
|
||||
gProxyFavIcon.setAttribute("src", aHref);
|
||||
|
||||
// update any bookmarks with new icon reference
|
||||
if (!gBookmarksService)
|
||||
gBookmarksService = Components.classes["@mozilla.org/browser/bookmarks-service;1"]
|
||||
.getService(Components.interfaces.nsIBookmarksService);
|
||||
gBookmarksService.UpdateBookmarkIcon(this.urlBar.value, aHref);
|
||||
}
|
||||
},
|
||||
|
||||
onProgressChange : function (aWebProgress, aRequest,
|
||||
|
||||
@@ -63,6 +63,10 @@ interface nsIBookmarksService : nsISupports
|
||||
void insertBookmarkInFolder(in string aURI, in wstring aTitle, in wstring docCharSet,
|
||||
in nsIRDFResource aFolder, in long aIndex);
|
||||
|
||||
void UpdateBookmarkIcon(in string aURL, in wstring iconURL);
|
||||
|
||||
void RemoveBookmarkIcon(in string aURL, in wstring iconURL);
|
||||
|
||||
void UpdateBookmarkLastVisitedDate(in string aURL, in wstring docCharset);
|
||||
|
||||
string FindShortcut(in wstring aName);
|
||||
|
||||
@@ -293,6 +293,7 @@
|
||||
<treecell class="treecell-indent" editable="true"
|
||||
label="rdf:http://home.netscape.com/NC-rdf#Name"
|
||||
src="rdf:http://home.netscape.com/NC-rdf#Icon"
|
||||
validate="never"
|
||||
type="rdf:http://www.w3.org/1999/02/22-rdf-syntax-ns#type"
|
||||
loading="rdf:http://home.netscape.com/NC-rdf#loading" />
|
||||
<treecell crop="center" class="treecell-editable" editable="true"
|
||||
|
||||
@@ -85,7 +85,9 @@
|
||||
#include "nsIIOService.h"
|
||||
#include "nsIChannel.h"
|
||||
#include "nsIHttpChannel.h"
|
||||
|
||||
#include "nsICacheService.h"
|
||||
#include "nsICacheSession.h"
|
||||
#include "nsICacheEntryDescriptor.h"
|
||||
|
||||
#include "nsIInputStream.h"
|
||||
#include "nsIInputStream.h"
|
||||
@@ -109,6 +111,7 @@ nsIRDFResource *kNC_FolderType;
|
||||
nsIRDFResource *kNC_IEFavorite;
|
||||
nsIRDFResource *kNC_IEFavoriteFolder;
|
||||
nsIRDFResource *kNC_Name;
|
||||
nsIRDFResource *kNC_Icon;
|
||||
nsIRDFResource *kNC_NewBookmarkFolder;
|
||||
nsIRDFResource *kNC_NewSearchFolder;
|
||||
nsIRDFResource *kNC_PersonalToolbarFolder;
|
||||
@@ -123,7 +126,7 @@ nsIRDFResource *kWEB_Status;
|
||||
nsIRDFResource *kWEB_LastPingDate;
|
||||
nsIRDFResource *kWEB_LastPingETag;
|
||||
nsIRDFResource *kWEB_LastPingModDate;
|
||||
nsIRDFResource *kWEB_LastCharset;
|
||||
nsIRDFResource *kWEB_LastCharset;
|
||||
nsIRDFResource *kWEB_LastPingContentLen;
|
||||
|
||||
nsIRDFResource *kNC_Parent;
|
||||
@@ -155,6 +158,7 @@ static NS_DEFINE_CID(kPrefCID, NS_PREF_CID);
|
||||
static NS_DEFINE_IID(kSoundCID, NS_SOUND_CID);
|
||||
static NS_DEFINE_CID(kStringBundleServiceCID, NS_STRINGBUNDLESERVICE_CID);
|
||||
static NS_DEFINE_CID(kPlatformCharsetCID, NS_PLATFORMCHARSET_CID);
|
||||
static NS_DEFINE_CID(kCacheServiceCID, NS_CACHESERVICE_CID);
|
||||
|
||||
#define URINC_BOOKMARKS_ROOT_STRING "NC:BookmarksRoot"
|
||||
|
||||
@@ -218,6 +222,7 @@ bm_AddRefGlobals()
|
||||
gRDF->GetResource(NC_NAMESPACE_URI "IEFavorite", &kNC_IEFavorite);
|
||||
gRDF->GetResource(NC_NAMESPACE_URI "IEFavoriteFolder", &kNC_IEFavoriteFolder);
|
||||
gRDF->GetResource(NC_NAMESPACE_URI "Name", &kNC_Name);
|
||||
gRDF->GetResource(NC_NAMESPACE_URI "Icon", &kNC_Icon);
|
||||
gRDF->GetResource(NC_NAMESPACE_URI "ShortcutURL", &kNC_ShortcutURL);
|
||||
gRDF->GetResource(NC_NAMESPACE_URI "URL", &kNC_URL);
|
||||
gRDF->GetResource(RDF_NAMESPACE_URI "type", &kRDF_type);
|
||||
@@ -287,6 +292,7 @@ bm_ReleaseGlobals()
|
||||
NS_IF_RELEASE(kNC_IEFavoriteFolder);
|
||||
NS_IF_RELEASE(kNC_IEFavoritesRoot);
|
||||
NS_IF_RELEASE(kNC_Name);
|
||||
NS_IF_RELEASE(kNC_Icon);
|
||||
NS_IF_RELEASE(kNC_NewBookmarkFolder);
|
||||
NS_IF_RELEASE(kNC_NewSearchFolder);
|
||||
NS_IF_RELEASE(kNC_PersonalToolbarFolder);
|
||||
@@ -531,6 +537,7 @@ static const char kLastVisitEquals[] = "LAST_VISIT=\"";
|
||||
static const char kLastModifiedEquals[] = "LAST_MODIFIED=\"";
|
||||
static const char kLastCharsetEquals[] = "LAST_CHARSET=\"";
|
||||
static const char kShortcutURLEquals[] = "SHORTCUTURL=\"";
|
||||
static const char kIconEquals[] = "ICON=\"";
|
||||
static const char kScheduleEquals[] = "SCHEDULE=\"";
|
||||
static const char kLastPingEquals[] = "LAST_PING=\"";
|
||||
static const char kPingETagEquals[] = "PING_ETAG=\"";
|
||||
@@ -1049,6 +1056,7 @@ BookmarkParser::gBookmarkFieldTable[] =
|
||||
{ kLastVisitEquals, WEB_NAMESPACE_URI "LastVisitDate", nsnull, BookmarkParser::ParseDate, nsnull },
|
||||
{ kLastModifiedEquals, WEB_NAMESPACE_URI "LastModifiedDate", nsnull, BookmarkParser::ParseDate, nsnull },
|
||||
{ kShortcutURLEquals, NC_NAMESPACE_URI "ShortcutURL", nsnull, BookmarkParser::ParseLiteral, nsnull },
|
||||
{ kIconEquals, NC_NAMESPACE_URI "Icon", nsnull, BookmarkParser::ParseLiteral, nsnull },
|
||||
{ kLastCharsetEquals, WEB_NAMESPACE_URI "LastCharset", nsnull, BookmarkParser::ParseLiteral, nsnull },
|
||||
{ kScheduleEquals, WEB_NAMESPACE_URI "Schedule", nsnull, BookmarkParser::ParseLiteral, nsnull },
|
||||
{ kLastPingEquals, WEB_NAMESPACE_URI "LastPingDate", nsnull, BookmarkParser::ParseDate, nsnull },
|
||||
@@ -1707,39 +1715,48 @@ nsBookmarksService::Init()
|
||||
rv = bm_AddRefGlobals();
|
||||
if (NS_FAILED(rv)) return(rv);
|
||||
|
||||
mNetService = do_GetService(kIOServiceCID, &rv);
|
||||
if (NS_FAILED(rv)) return(rv);
|
||||
|
||||
// create cache service/session, ignoring errors
|
||||
mCacheService = do_GetService(kCacheServiceCID, &rv);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
{
|
||||
rv = mCacheService->CreateSession("HTTP", nsICache::STORE_ANYWHERE,
|
||||
nsICache::STREAM_BASED, getter_AddRefs(mCacheSession));
|
||||
}
|
||||
|
||||
/* create a URL for the string resource file */
|
||||
nsCOMPtr<nsIIOService> pNetService;
|
||||
if (NS_SUCCEEDED(rv = nsServiceManager::GetService(kIOServiceCID, NS_GET_IID(nsIIOService),
|
||||
getter_AddRefs(pNetService))))
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
if (NS_SUCCEEDED(rv = mNetService->NewURI(bookmark_properties, nsnull,
|
||||
getter_AddRefs(uri))))
|
||||
{
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
if (NS_SUCCEEDED(rv = pNetService->NewURI(bookmark_properties, nsnull,
|
||||
getter_AddRefs(uri))))
|
||||
/* create a bundle for the localization */
|
||||
nsCOMPtr<nsIStringBundleService> stringService;
|
||||
if (NS_SUCCEEDED(rv = nsServiceManager::GetService(kStringBundleServiceCID,
|
||||
NS_GET_IID(nsIStringBundleService), getter_AddRefs(stringService))))
|
||||
{
|
||||
/* create a bundle for the localization */
|
||||
nsCOMPtr<nsIStringBundleService> stringService;
|
||||
if (NS_SUCCEEDED(rv = nsServiceManager::GetService(kStringBundleServiceCID,
|
||||
NS_GET_IID(nsIStringBundleService), getter_AddRefs(stringService))))
|
||||
char *spec = nsnull;
|
||||
if (NS_SUCCEEDED(rv = uri->GetSpec(&spec)) && (spec))
|
||||
{
|
||||
char *spec = nsnull;
|
||||
if (NS_SUCCEEDED(rv = uri->GetSpec(&spec)) && (spec))
|
||||
if (NS_SUCCEEDED(rv = stringService->CreateBundle(spec,
|
||||
getter_AddRefs(mBundle))))
|
||||
{
|
||||
if (NS_SUCCEEDED(rv = stringService->CreateBundle(spec,
|
||||
getter_AddRefs(mBundle))))
|
||||
{
|
||||
}
|
||||
nsCRT::free(spec);
|
||||
spec = nsnull;
|
||||
}
|
||||
nsCRT::free(spec);
|
||||
spec = nsnull;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// determine what the name of the Personal Toolbar Folder is...
|
||||
// first from user preference, then string bundle, then hard-coded default
|
||||
nsCOMPtr<nsIPref> prefServ(do_GetService(kPrefCID, &rv));
|
||||
if (NS_SUCCEEDED(rv) && (prefServ))
|
||||
{
|
||||
// get browser icon pref
|
||||
prefServ->GetBoolPref("browser.chrome.site_icons", &mBrowserIcons);
|
||||
|
||||
// determine what the name of the Personal Toolbar Folder is...
|
||||
// first from user preference, then string bundle, then hard-coded default
|
||||
char *prefVal = nsnull;
|
||||
if (NS_SUCCEEDED(rv = prefServ->CopyCharPref("custtoolbar.personal_toolbar_folder",
|
||||
&prefVal)) && (prefVal))
|
||||
@@ -2739,6 +2756,56 @@ nsBookmarksService::GetLastCharset(const char *aURI, PRUnichar **aLastCharset)
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsBookmarksService::UpdateBookmarkIcon(const char *aURL, const PRUnichar *iconURL)
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIRDFResource> bookmark;
|
||||
if (NS_FAILED(rv = gRDF->GetResource(aURL, getter_AddRefs(bookmark) )))
|
||||
{
|
||||
NS_ERROR("unable to get bookmark resource");
|
||||
return(rv);
|
||||
}
|
||||
nsCOMPtr<nsIRDFNode> favIconNode;
|
||||
if (NS_FAILED(rv = ProcessCachedBookmarkIcon(bookmark, iconURL,
|
||||
getter_AddRefs(favIconNode))))
|
||||
{
|
||||
return(rv);
|
||||
}
|
||||
if ((rv != NS_RDF_NO_VALUE) && favIconNode)
|
||||
{
|
||||
// yes, that's right; fake out RDF observers
|
||||
(void)OnAssert(this, bookmark, kNC_Icon, favIconNode);
|
||||
}
|
||||
return(NS_OK);
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsBookmarksService::RemoveBookmarkIcon(const char *aURL, const PRUnichar *iconURL)
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIRDFResource> bookmark;
|
||||
if (NS_FAILED(rv = gRDF->GetResource(aURL, getter_AddRefs(bookmark) )))
|
||||
{
|
||||
NS_ERROR("unable to get bookmark resource");
|
||||
return(rv);
|
||||
}
|
||||
nsCOMPtr<nsIRDFLiteral> iconLiteral;
|
||||
if (NS_FAILED(rv = gRDF->GetLiteral(iconURL, getter_AddRefs(iconLiteral))))
|
||||
{
|
||||
return(rv);
|
||||
}
|
||||
PRBool hasThisIconURL = PR_FALSE;
|
||||
if (NS_SUCCEEDED(rv = mInner->HasAssertion(bookmark, kNC_Icon, iconLiteral,
|
||||
PR_TRUE, &hasThisIconURL)) && (hasThisIconURL == PR_TRUE))
|
||||
{
|
||||
(void)mInner->Unassert(bookmark, kNC_Icon, iconLiteral);
|
||||
}
|
||||
return(NS_OK);
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsBookmarksService::UpdateBookmarkLastVisitedDate(const char *aURL, const PRUnichar *aCharset)
|
||||
{
|
||||
@@ -3009,6 +3076,11 @@ nsBookmarksService::GetTarget(nsIRDFResource* aSource,
|
||||
return(rv);
|
||||
}
|
||||
}
|
||||
else if (aProperty == kNC_Icon)
|
||||
{
|
||||
rv = ProcessCachedBookmarkIcon(aSource, nsnull, aTarget);
|
||||
return(rv);
|
||||
}
|
||||
|
||||
rv = mInner->GetTarget(aSource, aProperty, aTruthValue, aTarget);
|
||||
return(rv);
|
||||
@@ -3016,6 +3088,134 @@ nsBookmarksService::GetTarget(nsIRDFResource* aSource,
|
||||
|
||||
|
||||
|
||||
nsresult
|
||||
nsBookmarksService::ProcessCachedBookmarkIcon(nsIRDFResource* aSource,
|
||||
const PRUnichar *iconURL, nsIRDFNode** aTarget)
|
||||
{
|
||||
*aTarget = nsnull;
|
||||
|
||||
if (!mBrowserIcons)
|
||||
{
|
||||
return(NS_RDF_NO_VALUE);
|
||||
}
|
||||
|
||||
// if it is in fact a bookmark or favorite (but NOT a folder, or a separator, etc)...
|
||||
PRBool hasAssertion;
|
||||
mInner->HasAssertion(aSource, kRDF_type, kNC_Bookmark, PR_TRUE, &hasAssertion);
|
||||
if (!hasAssertion)
|
||||
{
|
||||
mInner->HasAssertion(aSource, kRDF_type, kNC_IEFavorite, PR_TRUE, &hasAssertion);
|
||||
}
|
||||
if (!hasAssertion)
|
||||
{
|
||||
return(NS_RDF_NO_VALUE);
|
||||
}
|
||||
|
||||
nsresult rv;
|
||||
nsCAutoString path;
|
||||
nsCOMPtr<nsIRDFNode> oldIconNode;
|
||||
|
||||
// if we have a new icon URL, save it away into our internal graph
|
||||
if (iconURL)
|
||||
{
|
||||
path.AssignWithConversion(iconURL);
|
||||
|
||||
nsCOMPtr<nsIRDFLiteral> iconLiteral;
|
||||
if (NS_FAILED(rv = gRDF->GetLiteral(iconURL, getter_AddRefs(iconLiteral))))
|
||||
{
|
||||
return(rv);
|
||||
}
|
||||
|
||||
rv = mInner->GetTarget(aSource, kNC_Icon, PR_TRUE, getter_AddRefs(oldIconNode));
|
||||
if (NS_SUCCEEDED(rv) && (rv != NS_RDF_NO_VALUE) && (oldIconNode))
|
||||
{
|
||||
(void)mInner->Unassert(aSource, kNC_Icon, oldIconNode);
|
||||
}
|
||||
(void)mInner->Assert(aSource, kNC_Icon, iconLiteral, PR_TRUE);
|
||||
}
|
||||
else
|
||||
{
|
||||
// otherwise, just check and see if we have an internal icon reference
|
||||
rv = mInner->GetTarget(aSource, kNC_Icon, PR_TRUE, getter_AddRefs(oldIconNode));
|
||||
}
|
||||
|
||||
if (oldIconNode)
|
||||
{
|
||||
nsCOMPtr<nsIRDFLiteral> tempLiteral = do_QueryInterface(oldIconNode);
|
||||
if (tempLiteral)
|
||||
{
|
||||
const PRUnichar *uni = nsnull;
|
||||
tempLiteral->GetValueConst(&uni);
|
||||
if (uni) path.AssignWithConversion(uni);
|
||||
}
|
||||
}
|
||||
|
||||
// if no internal icon reference, try and synthesize a URL
|
||||
if (!path.Length())
|
||||
{
|
||||
const char *uri;
|
||||
if (NS_FAILED(rv = aSource->GetValueConst( &uri )))
|
||||
{
|
||||
return(rv);
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIURI> nsURI;
|
||||
if (NS_FAILED(rv = mNetService->NewURI(uri, nsnull, getter_AddRefs(nsURI))))
|
||||
{
|
||||
return(rv);
|
||||
}
|
||||
|
||||
// only allow http/https URLs for favicon
|
||||
PRBool isHTTP = PR_FALSE;
|
||||
nsURI->SchemeIs("http", &isHTTP);
|
||||
if (!isHTTP)
|
||||
{
|
||||
nsURI->SchemeIs("https", &isHTTP);
|
||||
}
|
||||
if (!isHTTP)
|
||||
{
|
||||
return(NS_RDF_NO_VALUE);
|
||||
}
|
||||
|
||||
nsXPIDLCString prePath;
|
||||
if (NS_FAILED(rv = nsURI->GetPrePath(getter_Copies(prePath))))
|
||||
{
|
||||
return rv;
|
||||
}
|
||||
path.Assign(prePath);
|
||||
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);
|
||||
}
|
||||
nsCOMPtr<nsICacheEntryDescriptor> 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);
|
||||
}
|
||||
entry->Close();
|
||||
|
||||
// ok, have a cached icon entry, so return the URL's associated favicon
|
||||
nsAutoString litStr;
|
||||
litStr.AssignWithConversion(path.get());
|
||||
nsCOMPtr<nsIRDFLiteral> literal;
|
||||
if (NS_FAILED(rv = gRDF->GetLiteral(litStr.get(), getter_AddRefs(literal))))
|
||||
{
|
||||
return(rv);
|
||||
}
|
||||
*aTarget = literal;
|
||||
NS_IF_ADDREF(*aTarget);
|
||||
return(NS_OK);
|
||||
}
|
||||
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsBookmarksService::Assert(nsIRDFResource* aSource,
|
||||
nsIRDFResource* aProperty,
|
||||
@@ -4580,6 +4780,9 @@ nsBookmarksService::WriteBookmarksContainer(nsIRDFDataSource *ds, nsOutputFileSt
|
||||
// output SHORTCUTURL
|
||||
WriteBookmarkProperties(ds, strm, child, kNC_ShortcutURL, kShortcutURLEquals, PR_FALSE);
|
||||
|
||||
// output kNC_Icon
|
||||
WriteBookmarkProperties(ds, strm, child, kNC_Icon, kIconEquals, PR_FALSE);
|
||||
|
||||
// output SCHEDULE
|
||||
WriteBookmarkProperties(ds, strm, child, kWEB_Schedule, kScheduleEquals, PR_FALSE);
|
||||
|
||||
|
||||
@@ -51,6 +51,9 @@
|
||||
#include "nsIFileSpec.h"
|
||||
#include "nsIObserver.h"
|
||||
#include "nsWeakReference.h"
|
||||
#include "nsIIOService.h"
|
||||
#include "nsICacheService.h"
|
||||
#include "nsICacheSession.h"
|
||||
|
||||
#ifdef DEBUG
|
||||
#ifdef XP_MAC
|
||||
@@ -68,16 +71,20 @@ class nsBookmarksService : public nsIBookmarksService,
|
||||
{
|
||||
protected:
|
||||
nsIRDFDataSource* mInner;
|
||||
PRBool mBookmarksAvailable;
|
||||
PRBool mDirty;
|
||||
PRBool busySchedule;
|
||||
nsCOMPtr<nsIRDFResource> busyResource;
|
||||
PRUint32 htmlSize;
|
||||
nsCOMPtr<nsISupportsArray> mObservers;
|
||||
nsCOMPtr<nsIStringBundle> mBundle;
|
||||
nsString mPersonalToolbarName;
|
||||
PRInt32 mUpdateBatchNest;
|
||||
nsCOMPtr<nsITimer> mTimer;
|
||||
nsCOMPtr<nsIIOService> mNetService;
|
||||
nsCOMPtr<nsICacheService> mCacheService;
|
||||
nsCOMPtr<nsICacheSession> mCacheSession;
|
||||
PRUint32 htmlSize;
|
||||
PRInt32 mUpdateBatchNest;
|
||||
nsString mPersonalToolbarName;
|
||||
PRBool mBookmarksAvailable;
|
||||
PRBool mDirty;
|
||||
PRBool mBrowserIcons;
|
||||
PRBool busySchedule;
|
||||
|
||||
#ifdef XP_MAC
|
||||
PRBool mIEFavoritesAvailable;
|
||||
@@ -105,7 +112,7 @@ nsresult GetBookmarkToPing(nsIRDFResource **theBookmark);
|
||||
nsresult getFolderViaHint(nsIRDFResource *src, PRBool fallbackFlag, nsIRDFResource **folder);
|
||||
nsresult importBookmarks(nsISupportsArray *aArguments);
|
||||
nsresult exportBookmarks(nsISupportsArray *aArguments);
|
||||
|
||||
nsresult ProcessCachedBookmarkIcon(nsIRDFResource* aSource, const PRUnichar *iconURL, nsIRDFNode** aTarget);
|
||||
nsresult getResourceFromLiteralNode(nsIRDFNode *node, nsIRDFResource **res);
|
||||
|
||||
nsresult ChangeURL(nsIRDFResource* aOldURL,
|
||||
|
||||
@@ -71,7 +71,7 @@
|
||||
<content>
|
||||
<xul:hbox class="menu-iconic-left" align="center" pack="center"
|
||||
inherits="selected,menuactive,disabled,checked">
|
||||
<xul:image inherits="src"/>
|
||||
<xul:image class="menu-iconic-icon" inherits="validate,src"/>
|
||||
</xul:hbox>
|
||||
<xul:label class="menu-iconic-text" flex="1" inherits="value=label,accesskey,crop" crop="right"/>
|
||||
<xul:label class="menu-iconic-accel" inherits="value=acceltext"/>
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
<xul:hbox class="box-inherit toolbarbutton-box"
|
||||
inherits="align,dir,pack,orient" flex="1">
|
||||
<children>
|
||||
<xul:image class="toolbarbutton-icon" inherits="src=image"/>
|
||||
<xul:image class="toolbarbutton-icon" inherits="validate,src=image"/>
|
||||
<xul:label class="toolbarbutton-text" crop="right" flex="1"
|
||||
inherits="value=label,accesskey,crop,dragover-top"/>
|
||||
</children>
|
||||
@@ -30,7 +30,7 @@
|
||||
<xul:hbox class="box-inherit toolbarbutton-box"
|
||||
inherits="align,dir,pack,orient" flex="1">
|
||||
<children>
|
||||
<xul:image class="toolbarbutton-icon" inherits="src=image"/>
|
||||
<xul:image class="toolbarbutton-icon" inherits="validate,src=image"/>
|
||||
<xul:label class="toolbarbutton-text" crop="right" flex="1"
|
||||
inherits="value=label,accesskey,crop,dragover-top"/>
|
||||
</children>
|
||||
|
||||
@@ -452,7 +452,7 @@
|
||||
<binding id="treecell-iconic"
|
||||
extends="chrome://global/content/bindings/tree.xml#tree-base">
|
||||
<content>
|
||||
<xul:image class="tree-cell-icon" inherits="src"/>
|
||||
<xul:image class="tree-cell-icon" inherits="validate,src"/>
|
||||
<xul:label class="tree-cell-text" inherits="crop,value=label,align" flex="1" crop="right"/>
|
||||
</content>
|
||||
</binding>
|
||||
@@ -460,7 +460,7 @@
|
||||
<binding id="treecell-image"
|
||||
extends="chrome://global/content/bindings/tree.xml#tree-base">
|
||||
<content>
|
||||
<xul:image class="tree-cell-image" inherits="src"/>
|
||||
<xul:image class="tree-cell-image" inherits="validate,src"/>
|
||||
</content>
|
||||
</binding>
|
||||
|
||||
@@ -469,7 +469,7 @@
|
||||
<content>
|
||||
<xul:treeindentation/>
|
||||
<xul:image class="tree-cell-twisty" twisty="true" inherits="hidden=notwisty" allowevents="true"/>
|
||||
<xul:image class="tree-cell-primary-icon" inherits="src"/>
|
||||
<xul:image class="tree-cell-primary-icon" inherits="validate,src"/>
|
||||
<xul:label class="tree-cell-text" inherits="crop,value=label,align" flex="1" crop="right"/>
|
||||
</content>
|
||||
</binding>
|
||||
@@ -484,7 +484,7 @@
|
||||
<content>
|
||||
<xul:treeindentation/>
|
||||
<xul:image class="tree-cell-twisty" twisty="true" inherits="hidden=notwisty" allowevents="true"/>
|
||||
<xul:image class="tree-cell-primary-icon-inline-edit-folder" inherits="src"/>
|
||||
<xul:image class="tree-cell-primary-icon-inline-edit-folder" inherits="validate,src"/>
|
||||
<xul:hbox class="inline-edit-cell-box" flex="1" ileattr="text-container">
|
||||
<xul:label class="inline-edit-cell-text" ileattr="text" rootcontent="treecell"
|
||||
inherits="crop,value=label,align,mode" flex="1" crop="right"/>
|
||||
@@ -501,7 +501,7 @@
|
||||
|
||||
<content>
|
||||
<xul:treeindentation/>
|
||||
<xul:image class="tree-cell-primary-icon" inherits="src"/>
|
||||
<xul:image class="tree-cell-primary-icon" inherits="validate,src"/>
|
||||
<xul:hbox class="inline-edit-cell-box" flex="1" ileattr="text-container">
|
||||
<xul:label class="tree-cell-text" ileattr="text" rootcontent="treecell"
|
||||
inherits="crop,value=label,align,mode" flex="1" crop="right"/>
|
||||
@@ -528,7 +528,7 @@
|
||||
extends="chrome://global/content/bindings/tree.xml#tree-base">
|
||||
<content>
|
||||
<xul:treeindentation/>
|
||||
<xul:image class="tree-cell-primary-icon" inherits="src"/>
|
||||
<xul:image class="tree-cell-primary-icon" inherits="validate,src"/>
|
||||
<xul:label class="tree-cell-text" inherits="crop,value=label,align" flex="1" crop="right"/>
|
||||
</content>
|
||||
</binding>
|
||||
@@ -541,7 +541,7 @@
|
||||
extends="chrome://global/content/bindings/tree.xml#tree-base">
|
||||
<content>
|
||||
<xul:hbox class="treecell-header-box" flex="1" align="center">
|
||||
<xul:image class="tree-header-image" inherits="src"/>
|
||||
<xul:image class="tree-header-image" inherits="validate,src"/>
|
||||
<xul:label class="tree-header-text" inherits="crop,value=label,disabled" flex="1" crop="right"/>
|
||||
<xul:image class="tree-header-sortdirection"/>
|
||||
</xul:hbox>
|
||||
@@ -552,7 +552,7 @@
|
||||
extends="chrome://global/content/bindings/tree.xml#tree-base">
|
||||
<content>
|
||||
<xul:hbox class="treecell-header-image-box" flex="1" align="center">
|
||||
<xul:image class="tree-header-image" inherits="src"/>
|
||||
<xul:image class="tree-header-image" inherits="validate,src"/>
|
||||
</xul:hbox>
|
||||
</content>
|
||||
</binding>
|
||||
|
||||
Reference in New Issue
Block a user