Reviewed by John
authorbeidson <beidson@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 10 Oct 2006 02:10:48 +0000 (02:10 +0000)
committerbeidson <beidson@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 10 Oct 2006 02:10:48 +0000 (02:10 +0000)
        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

WebKit/ChangeLog
WebKit/Misc/WebIconDatabase.h
WebKit/Misc/WebIconDatabase.m
WebKit/Misc/WebIconDatabaseDelegate.h [new file with mode: 0644]
WebKit/Misc/WebIconDatabasePrivate.h
WebKit/WebKit.xcodeproj/project.pbxproj

index 71a1ffa9b68cd2855ded2b65610e54295dfe5ac6..c3366ef0ef682efbc9e75bf062d26eb4bc4d795f 100644 (file)
@@ -1,3 +1,22 @@
+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.
index fbd8fbdba03ada5702ab28876f4af1e04a134413..8104f151fda6ba12f7d8d7d9ce4aa9764cc7940b 100644 (file)
@@ -106,6 +106,7 @@ extern NSSize WebIconLargeSize;  // 128 x 128
     @param size
 */
 - (NSImage *)defaultIconWithSize:(NSSize)size;
+- (NSImage *)defaultIconForURL:(NSString *)URL withSize:(NSSize)size;
 
 /*!
     @method retainIconForURL:
@@ -121,6 +122,9 @@ extern NSSize WebIconLargeSize;  // 128 x 128
 */
 - (void)releaseIconForURL:(NSString *)URL;
 
+- (void)setDelegate:(id)delegate;
+- (id)delegate;
+
 @end
 
 
index 1c79c039a0cbe988a5d52aa3f9b7acc5838586f9..8fbd9e6508857ee1925756ef10cf99525498b07e 100644 (file)
@@ -27,6 +27,7 @@
  */
 #import <WebKit/WebIconDatabase.h>
 
+#import "WebIconDatabaseDelegate.h"
 #import <WebKit/WebIconDatabasePrivate.h>
 #import <WebKit/WebKitLogging.h>
 #import <WebKit/WebKitNSStringExtras.h>
@@ -80,7 +81,7 @@ NSSize WebIconLargeSize = {128, 128};
     [super init];
     
     _private = [[WebIconDatabasePrivate alloc] init];
-
+    
     // Get/create the shared database bridge - bail if we fail
     _private->databaseBridge = [WebIconDatabaseBridge sharedInstance];
     if (!_private->databaseBridge) {
@@ -135,14 +136,16 @@ NSSize WebIconLargeSize = {128, 128};
     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
@@ -167,6 +170,13 @@ NSSize WebIconLargeSize = {128, 128};
     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);
@@ -184,6 +194,18 @@ NSSize WebIconLargeSize = {128, 128};
 
     [_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
 
 
diff --git a/WebKit/Misc/WebIconDatabaseDelegate.h b/WebKit/Misc/WebIconDatabaseDelegate.h
new file mode 100644 (file)
index 0000000..ad6aed2
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * 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
+
+
index 3b04828bbb104f35ad4c697de730aa22c66a322b..122101e88219b3cf9ffb5f42bbddac0a8434e116 100644 (file)
@@ -29,7 +29,7 @@
 #import <Cocoa/Cocoa.h>
 #import <WebKit/WebIconDatabase.h>
 
-@class WebFileDatabase;
+
 @class WebCoreIconDatabaseBridge;
 @class WebDataSource;
 
@@ -37,6 +37,9 @@
 
 @public
     WebCoreIconDatabaseBridge *databaseBridge;
+    id delegate;
+    
+    BOOL delegateDefaultIconForURL;
     
     NSMutableDictionary *htmlIcons;
     NSMutableDictionary *defaultIcons;
index a60512b2cfe1a5a7c3aebf332084c08af659212f..e79cba0d9b8df2541364989dfcb54e50a9dadd4a 100644 (file)
@@ -34,6 +34,7 @@
                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 */,
                        );