Reviewed by John
<rdar://problem/
4707718> - Instead of faking the user out with an in-memory icon database if their
~/Library/Safari/Icons is unwritable, we'll actually fail to open the icon database and the app will
run as if it was disabled via a preference.
Also took the opportunity to change some ASSERTS() to reasonable behavior
* bridge/mac/WebCoreIconDatabaseBridge.mm:
(-[WebCoreIconDatabaseBridge openSharedDatabaseWithPath:]): NSLog on failure so the user has a chance to figure
out there's a problem.
(-[WebCoreIconDatabaseBridge closeSharedDatabase]):
(-[WebCoreIconDatabaseBridge iconForPageURL:withSize:]): From here on, just replaced ASSERTS() with reasonable behavior
(-[WebCoreIconDatabaseBridge iconURLForPageURL:]):
(-[WebCoreIconDatabaseBridge defaultIconWithSize:]):
(-[WebCoreIconDatabaseBridge retainIconForURL:]):
(-[WebCoreIconDatabaseBridge releaseIconForURL:]):
(-[WebCoreIconDatabaseBridge _setIconData:forIconURL:]):
(-[WebCoreIconDatabaseBridge _setHaveNoIconForIconURL:]):
(-[WebCoreIconDatabaseBridge _setIconURL:forPageURL:]):
(-[WebCoreIconDatabaseBridge _hasEntryForIconURL:]):
* loader/icon/IconDatabase.cpp:
(WebCore::IconDatabase::open): If we fail to open, return false
(WebCore::IconDatabase::~IconDatabase): cleanup better
* loader/icon/IconDatabase.h:
WebKit:
Reviewed by John
<rdar://problem/
4707718> Change behavior so if the WebCore::IconDatabase can't open, WebKit releases the bridge and
continues on as if the IconDatabase is disabled.
* Misc/WebIconDatabase.m:
(-[WebIconDatabase init]): Release the bridge on failure to open
* WebCoreSupport/WebIconDatabaseBridge.m:
(+[WebIconDatabaseBridge sharedBridgeInstance]): Moved static shared instance out as a global
(-[WebIconDatabaseBridge dealloc]): Clear pointer to the shared instance
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@16132
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2006-08-30 Brady Eidson <beidson@apple.com>
+
+ Reviewed by John
+
+ <rdar://problem/4707718> - Instead of faking the user out with an in-memory icon database if their
+ ~/Library/Safari/Icons is unwritable, we'll actually fail to open the icon database and the app will
+ run as if it was disabled via a preference.
+ Also took the opportunity to change some ASSERTS() to reasonable behavior
+
+ * bridge/mac/WebCoreIconDatabaseBridge.mm:
+ (-[WebCoreIconDatabaseBridge openSharedDatabaseWithPath:]): NSLog on failure so the user has a chance to figure
+ out there's a problem.
+ (-[WebCoreIconDatabaseBridge closeSharedDatabase]):
+ (-[WebCoreIconDatabaseBridge iconForPageURL:withSize:]): From here on, just replaced ASSERTS() with reasonable behavior
+ (-[WebCoreIconDatabaseBridge iconURLForPageURL:]):
+ (-[WebCoreIconDatabaseBridge defaultIconWithSize:]):
+ (-[WebCoreIconDatabaseBridge retainIconForURL:]):
+ (-[WebCoreIconDatabaseBridge releaseIconForURL:]):
+ (-[WebCoreIconDatabaseBridge _setIconData:forIconURL:]):
+ (-[WebCoreIconDatabaseBridge _setHaveNoIconForIconURL:]):
+ (-[WebCoreIconDatabaseBridge _setIconURL:forPageURL:]):
+ (-[WebCoreIconDatabaseBridge _hasEntryForIconURL:]):
+ * loader/icon/IconDatabase.cpp:
+ (WebCore::IconDatabase::open): If we fail to open, return false
+ (WebCore::IconDatabase::~IconDatabase): cleanup better
+ * loader/icon/IconDatabase.h:
+
2006-08-30 David Harrison <harrison@apple.com>
Reviewed by John Sullivan.
_iconDB = IconDatabase::sharedIconDatabase();
if (_iconDB) {
_iconDB->open((String([path stringByStandardizingPath])));
- return _iconDB->isOpen() ? YES : NO;
+ if (!_iconDB->isOpen()) {
+ [self closeSharedDatabase];
+ NSLog(@"Unable to open icon database at %@ - Check your write permissions at that path. Icon database will be disabled for this browsing session", path);
+ return NO;
+ }
+ return YES;
}
return NO;
}
- (void)closeSharedDatabase
{
- if (_iconDB) {
- _iconDB->close();
- _iconDB = 0;
- }
+ delete _iconDB;
+ _iconDB = 0;
}
- (BOOL)isOpen
- (NSImage *)iconForPageURL:(NSString *)url withSize:(NSSize)size
{
- ASSERT(_iconDB);
+ if (!_iconDB)
+ return nil;
+
ASSERT(url);
ASSERT(size.width);
ASSERT(size.height);
- (NSString *)iconURLForPageURL:(NSString *)url
{
- ASSERT(_iconDB);
+ if (!_iconDB)
+ return nil;
ASSERT(url);
String iconURL = _iconDB->iconURLForPageURL(String(url));
- (NSImage *)defaultIconWithSize:(NSSize)size
{
- ASSERT(_iconDB);
+ if (!_iconDB)
+ return nil;
ASSERT(size.width);
ASSERT(size.height);
- (void)retainIconForURL:(NSString *)url
{
- ASSERT(_iconDB);
+ if (!_iconDB)
+ return;
ASSERT(url);
_iconDB->retainIconForPageURL(String(url));
}
- (void)releaseIconForURL:(NSString *)url
{
- ASSERT(_iconDB);
+ if (!_iconDB)
+ return;
ASSERT(url);
_iconDB->releaseIconForPageURL(String(url));
}
- (void)_setIconData:(NSData *)data forIconURL:(NSString *)iconURL
{
- ASSERT(_iconDB);
+ if (!_iconDB)
+ return;
ASSERT(data);
ASSERT(iconURL);
- (void)_setHaveNoIconForIconURL:(NSString *)iconURL
{
- ASSERT(_iconDB);
+ if (!_iconDB)
+ return;
ASSERT(iconURL);
_iconDB->setHaveNoIconForIconURL(String(iconURL));
- (BOOL)_setIconURL:(NSString *)iconURL forPageURL:(NSString *)pageURL
{
- ASSERT(_iconDB);
+ if (!_iconDB)
+ return NO;
ASSERT(iconURL);
ASSERT(pageURL);
- (BOOL)_hasEntryForIconURL:(NSString *)iconURL
{
- ASSERT(_iconDB);
+ if (!_iconDB)
+ return NO;
ASSERT(iconURL);
return _iconDB->hasEntryForIconURL(iconURL);
dbFilename = databasePath + "/" + defaultDatabaseFilename();
// <rdar://problem/4707718> - If user's Icon directory is unwritable, Safari will crash at startup
- // Now, we'll see if we can open the on-disk database. If we can't, we'll log the error and open it as
- // an in-memory database so the user will have icons during their current browsing session
-
+ // Now, we'll see if we can open the on-disk database. And, if we can't, we'll return false.
+ // WebKit will then ignore us and act as if the database is disabled
if (!m_mainDB.open(dbFilename)) {
LOG_ERROR("Unable to open icon database at path %s - %s", dbFilename.ascii().data(), m_mainDB.lastErrorMsg());
- if (!m_mainDB.open(":memory:"))
- LOG_ERROR("Unable to open in-memory database for browsing - %s", m_mainDB.lastErrorMsg());
+ return false;
}
if (!isValidDatabase(m_mainDB)) {
IconDatabase::~IconDatabase()
{
close();
+ m_startupTimer.stop();
+ m_updateTimer.stop();
+ if (m_sharedInstance == this)
+ m_sharedInstance = 0;
}
// readySQLStatement() handles two things
friend class SiteIcon;
public:
static IconDatabase* sharedIconDatabase();
-
+ ~IconDatabase();
+
bool open(const String& path);
bool isOpen() { return m_mainDB.isOpen() && m_privateBrowsingDB.isOpen(); }
void close();
static const int updateTimerDelay;
private:
IconDatabase();
- ~IconDatabase();
// This tries to get the iconID for the IconURL and, if it doesn't exist and createIfNecessary is true,
// it will create the entry and return the new iconID
+2006-08-30 Brady Eidson <beidson@apple.com>
+
+ Reviewed by John
+
+ <rdar://problem/4707718> Change behavior so if the WebCore::IconDatabase can't open, WebKit releases the bridge and
+ continues on as if the IconDatabase is disabled.
+
+ * Misc/WebIconDatabase.m:
+ (-[WebIconDatabase init]): Release the bridge on failure to open
+ * WebCoreSupport/WebIconDatabaseBridge.m:
+ (+[WebIconDatabaseBridge sharedBridgeInstance]): Moved static shared instance out as a global
+ (-[WebIconDatabaseBridge dealloc]): Clear pointer to the shared instance
+
2006-08-30 Timothy Hatcher <timothy@apple.com>
Reviewed by Darin.
databaseDirectory = [databaseDirectory stringByExpandingTildeInPath];
// Open the WebCore icon database
- [_private->databaseBridge openSharedDatabaseWithPath:databaseDirectory];
+ if (![_private->databaseBridge openSharedDatabaseWithPath:databaseDirectory]) {
+ LOG_ERROR("Unable to open IconDatabaseBridge");
+ [_private->databaseBridge release];
+ _private->databaseBridge = nil;
+ return self;
+ }
[_private->databaseBridge setPrivateBrowsingEnabled:[[WebPreferences standardPreferences] privateBrowsingEnabled]];
// <rdar://problem/4674552> New IconDB: New Safari icon database needs to convert from the old icons on first load
return self;
}
-- (void)dealloc
-{
- [cachedLoaders release];
- [super dealloc];
-}
-
- (void)loadIconFromURL:(NSString *)iconURL
{
if ([cachedLoaders valueForKey:iconURL])
}
}
+static WebCoreIconDatabaseBridge* g_sharedBridgeInstance = nil;
+ (WebCoreIconDatabaseBridge *)sharedBridgeInstance
{
- static WebCoreIconDatabaseBridge* sharedBridgeInstance = nil;
- if (!sharedBridgeInstance)
- sharedBridgeInstance = [[WebIconDatabaseBridge alloc] init];
- return sharedBridgeInstance;
+ if (!g_sharedBridgeInstance)
+ g_sharedBridgeInstance = [[WebIconDatabaseBridge alloc] init];
+ return g_sharedBridgeInstance;
+}
+
+- (void)dealloc
+{
+ ASSERT(self == g_sharedBridgeInstance);
+ g_sharedBridgeInstance = nil;
+ [cachedLoaders release];
+ [super dealloc];
}
@end