http://bugs.webkit.org/show_bug.cgi?id=11195
Added the WebIconDatabaseDelegate. This allows the ability to allow customization of
IconDatabase behavior in the future, starting now with the ability to override the
default icon fairly flexibly
* Misc/WebIconDatabase.h: Added setIconDatabaseDelegate:
* Misc/WebIconDatabase.m:
(-[WebIconDatabase iconForURL:withSize:cache:]): Call the delegate for the default icon if delegate is set
(-[WebIconDatabase defaultIconForURL:withSize:]): Get the default icon through the delegate if available, built-in if not
(-[WebIconDatabase setDelegate:]):
(-[WebIconDatabase delegate]):
* Misc/WebIconDatabaseDelegate.h: Added.
* Misc/WebIconDatabasePrivate.h: Added the delegate, nuked an unused class definition
* WebKit.xcodeproj/project.pbxproj:
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@16956
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2006-10-09 Brady Eidson <beidson@apple.com>
+
+ Reviewed by John
+
+ http://bugs.webkit.org/show_bug.cgi?id=11195
+ Added the WebIconDatabaseDelegate. This allows the ability to allow customization of
+ IconDatabase behavior in the future, starting now with the ability to override the
+ default icon fairly flexibly
+
+ * Misc/WebIconDatabase.h: Added setIconDatabaseDelegate:
+ * Misc/WebIconDatabase.m:
+ (-[WebIconDatabase iconForURL:withSize:cache:]): Call the delegate for the default icon if delegate is set
+ (-[WebIconDatabase defaultIconForURL:withSize:]): Get the default icon through the delegate if available, built-in if not
+ (-[WebIconDatabase setDelegate:]):
+ (-[WebIconDatabase delegate]):
+ * Misc/WebIconDatabaseDelegate.h: Added.
+ * Misc/WebIconDatabasePrivate.h: Added the delegate, nuked an unused class definition
+ * WebKit.xcodeproj/project.pbxproj:
+
2006-10-09 Darin Adler <darin@apple.com>
Reviewed by Maciej.
@param size
*/
- (NSImage *)defaultIconWithSize:(NSSize)size;
+- (NSImage *)defaultIconForURL:(NSString *)URL withSize:(NSSize)size;
/*!
@method retainIconForURL:
*/
- (void)releaseIconForURL:(NSString *)URL;
+- (void)setDelegate:(id)delegate;
+- (id)delegate;
+
@end
*/
#import <WebKit/WebIconDatabase.h>
+#import "WebIconDatabaseDelegate.h"
#import <WebKit/WebIconDatabasePrivate.h>
#import <WebKit/WebKitLogging.h>
#import <WebKit/WebKitNSStringExtras.h>
[super init];
_private = [[WebIconDatabasePrivate alloc] init];
-
+
// Get/create the shared database bridge - bail if we fail
_private->databaseBridge = [WebIconDatabaseBridge sharedInstance];
if (!_private->databaseBridge) {
ASSERT(size.height);
if (!URL || ![self _isEnabled])
- return [self defaultIconWithSize:size];
+ return [self defaultIconForURL:URL withSize:size];
// FIXME - <rdar://problem/4697934> - Move the handling of FileURLs to WebCore and implement in ObjC++
if ([URL _webkit_isFileURL])
return [self _iconForFileURL:URL withSize:size];
NSImage* image = [_private->databaseBridge iconForPageURL:URL withSize:size];
- return image ? image : [self defaultIconWithSize:size];
+ if (image)
+ return image;
+ return [self defaultIconForURL:URL withSize:size];
}
- (NSImage *)iconForURL:(NSString *)URL withSize:(NSSize)size
return [_private->databaseBridge defaultIconWithSize:size];
}
+- (NSImage *)defaultIconForURL:(NSString *)URL withSize:(NSSize)size
+{
+ if (_private->delegateDefaultIconForURL)
+ return [_private->delegate webIconDatabase:self defaultIconForURL:URL withSize:size];
+ return [_private->databaseBridge defaultIconWithSize:size];
+}
+
- (void)retainIconForURL:(NSString *)URL
{
ASSERT(URL);
[_private->databaseBridge releaseIconForURL:pageURL];
}
+
+- (void)setDelegate:(id)delegate
+{
+ _private->delegate = delegate;
+ _private->delegateDefaultIconForURL = [delegate respondsToSelector:@selector(webIconDatabase:defaultIconForURL:withSize:)];
+}
+
+- (id)delegate
+{
+ return _private->delegate;
+}
+
@end
--- /dev/null
+/*
+ * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+@interface NSObject (WebIconDatabaseDelegate)
+
+- (NSImage *)webIconDatabase:(WebIconDatabase *)webIconDatabase defaultIconForURL:(NSString *)URL withSize:(NSSize)size;
+
+@end
+
+
#import <Cocoa/Cocoa.h>
#import <WebKit/WebIconDatabase.h>
-@class WebFileDatabase;
+
@class WebCoreIconDatabaseBridge;
@class WebDataSource;
@public
WebCoreIconDatabaseBridge *databaseBridge;
+ id delegate;
+
+ BOOL delegateDefaultIconForURL;
NSMutableDictionary *htmlIcons;
NSMutableDictionary *defaultIcons;
22E42A4F0A5B9F620003275B /* OpenGL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 22E42A4E0A5B9F620003275B /* OpenGL.framework */; };
22E42A9A0A5BA4D00003275B /* AGL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 22E42A990A5BA4D00003275B /* AGL.framework */; };
22F219CC08D236730030E078 /* WebBackForwardListPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = 22F219CB08D236730030E078 /* WebBackForwardListPrivate.h */; settings = {ATTRIBUTES = (Private, ); }; };
+ 51B2A1000ADB15D0002A9BEE /* WebIconDatabaseDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = 51B2A0FF0ADB15D0002A9BEE /* WebIconDatabaseDelegate.h */; };
51E4D3990A886B5E00ECEE2C /* WebIconDatabaseBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 51E4D3970A886B5E00ECEE2C /* WebIconDatabaseBridge.h */; };
51E4D39A0A886B5E00ECEE2C /* WebIconDatabaseBridge.m in Sources */ = {isa = PBXBuildFile; fileRef = 51E4D3980A886B5E00ECEE2C /* WebIconDatabaseBridge.m */; };
650F74E409E488F70020118A /* WebUnarchivingState.h in Headers */ = {isa = PBXBuildFile; fileRef = 650F74E209E488F70020118A /* WebUnarchivingState.h */; };
51A8B579042834F700CA2D3A /* WebView.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = WebView.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
51A8B57A042834F700CA2D3A /* WebView.m */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.objc; path = WebView.m; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
51A8B57D0428353A00CA2D3A /* WebViewPrivate.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = WebViewPrivate.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
+ 51B2A0FF0ADB15D0002A9BEE /* WebIconDatabaseDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebIconDatabaseDelegate.h; sourceTree = "<group>"; };
51C16E4006138EB400A1657B /* npfunctions.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = npfunctions.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
51E4D3970A886B5E00ECEE2C /* WebIconDatabaseBridge.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = WebIconDatabaseBridge.h; sourceTree = "<group>"; };
51E4D3980A886B5E00ECEE2C /* WebIconDatabaseBridge.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; path = WebIconDatabaseBridge.m; sourceTree = "<group>"; };
F528E3E9031E91AD01CA2ACA /* WebIconDatabase.h */,
F528E3EA031E91AD01CA2ACA /* WebIconDatabase.m */,
F528E3EB031E91AD01CA2ACA /* WebIconDatabasePrivate.h */,
+ 51B2A0FF0ADB15D0002A9BEE /* WebIconDatabaseDelegate.h */,
2568C72C0174912D0ECA149E /* WebKit.h */,
F5927D4E02D26C5E01CA2DBB /* WebKitErrors.h */,
83730F9803FB1E660004736E /* WebKitErrors.m */,
65FFB7FC0AD0B7D30048CD05 /* WebDocumentLoaderMac.h in Headers */,
930653940AD6FEF6008E969A /* WebFrameLoaderClient.h in Headers */,
656D8B540ADA4EA400B34CBB /* WebFormState.h in Headers */,
+ 51B2A1000ADB15D0002A9BEE /* WebIconDatabaseDelegate.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
0867D690FE84028FC02AAC07 /* Project object */ = {
isa = PBXProject;
buildConfigurationList = 149C283208902B0F008A9EFC /* Build configuration list for PBXProject "WebKit" */;
- compatibilityVersion = "Xcode 2.4";
hasScannedForEncodings = 1;
knownRegions = (
English,
productRefGroup = 034768DFFF38A50411DB9C8B /* Products */;
projectDirPath = "";
projectRoot = "";
- shouldCheckCompatibility = 1;
targets = (
9398100A0824BF01008DF038 /* WebKit */,
);