+ope2006-09-20 Brady Eidson <beidson@apple.com>
+
+ Reviewed by Darin
+
+ Cleaned up my last patch alot, and made the WebCore icon database disabled by default
+
+ * loader/icon/IconDatabase.cpp:
+ (WebCore::IconDatabase::IconDatabase): Disabled by default
+ (WebCore::IconDatabase::removeAllIcons): Respect just isOpen() (disabled database will always be closed)
+ (WebCore::IconDatabase::setPrivateBrowsingEnabled): Ditto
+ (WebCore::IconDatabase::iconForPageURL): Ditto
+ (WebCore::IconDatabase::isIconExpiredForIconURL): Ditto
+ (WebCore::IconDatabase::iconURLForPageURL): Ditto
+ (WebCore::IconDatabase::retainIconForPageURL): Ditto
+ (WebCore::IconDatabase::releaseIconForPageURL): Ditto
+ (WebCore::IconDatabase::setIconDataForIconURL): Ditto
+ (WebCore::IconDatabase::setIconURLForPageURL): Ditto
+ (WebCore::IconDatabase::hasEntryForIconURL): Ditto
+ (WebCore::IconDatabase::setEnabled): Fixed a big bug here!
+
2006-09-20 Adam Roben <aroben@apple.com>
Reviewed by Adele.
, m_imageDataForIconURLStatement(0)
, m_currentDB(&m_mainDB)
, m_defaultIconDataCache(0)
- , m_isEnabled(true)
+ , m_isEnabled(false)
, m_privateBrowsingEnabled(false)
, m_startupTimer(this, &IconDatabase::pruneUnretainedIconsOnStartup)
, m_updateTimer(this, &IconDatabase::updateDatabase)
void IconDatabase::removeAllIcons()
{
- if (!m_isEnabled || !isOpen())
+ if (!isOpen())
return;
// We don't need to sync anything anymore since we're wiping everything.
void IconDatabase::setPrivateBrowsingEnabled(bool flag)
{
- if (!m_isEnabled || !isOpen())
+ if (!isOpen())
return;
if (m_privateBrowsingEnabled == flag)
return;
Image* IconDatabase::iconForPageURL(const String& pageURL, const IntSize& size, bool cache)
{
- if (!m_isEnabled || !isOpen())
+ if (!isOpen())
return defaultIcon(size);
// See if we even have an IconURL for this PageURL...
// iconExpirationTime to present icons, and missingIconExpirationTime for missing icons
bool IconDatabase::isIconExpiredForIconURL(const String& iconURL)
{
- // If we're disabled and someone is making this call, it is likely a return value of
+ // If we're closed and someone is making this call, it is likely a return value of
// false will discourage them to take any further action, which is our goal in this case
// Same notion for an empty iconURL - which is now defined as "never expires"
- if (!m_isEnabled || !isOpen() || iconURL.isEmpty())
+ if (!isOpen() || iconURL.isEmpty())
return false;
// If we have a IconDataCache, then it definitely has the Timestamp in it
String IconDatabase::iconURLForPageURL(const String& pageURL)
{
- if (!m_isEnabled || !isOpen() || pageURL.isEmpty())
+ if (!isOpen() || pageURL.isEmpty())
return String();
if (m_pageURLToIconURLMap.contains(pageURL))
void IconDatabase::retainIconForPageURL(const String& pageURL)
{
- if (!m_isEnabled || !isOpen() || pageURL.isEmpty())
+ if (!isOpen() || pageURL.isEmpty())
return;
// If we don't have the retain count for this page, we need to setup records of its retain
void IconDatabase::releaseIconForPageURL(const String& pageURL)
{
- if (!m_isEnabled || !isOpen() || pageURL.isEmpty())
+ if (!isOpen() || pageURL.isEmpty())
return;
// Check if this pageURL is actually retained
void IconDatabase::setIconDataForIconURL(const void* data, int size, const String& iconURL)
{
ASSERT(size > -1);
- if (!m_isEnabled || !isOpen() || iconURL.isEmpty())
+ if (!isOpen() || iconURL.isEmpty())
return;
if (size)
bool IconDatabase::setIconURLForPageURL(const String& iconURL, const String& pageURL)
{
ASSERT(!iconURL.isEmpty());
- if (!m_isEnabled || !isOpen() || pageURL.isEmpty())
+ if (!isOpen() || pageURL.isEmpty())
return false;
// If the urls already map to each other, bail.
bool IconDatabase::hasEntryForIconURL(const String& iconURL)
{
- if (!m_isEnabled || !isOpen() || iconURL.isEmpty())
+ if (!isOpen() || iconURL.isEmpty())
return false;
// First check the in memory mapped icons...
void IconDatabase::setEnabled(bool enabled)
{
- if (isOpen())
+ if (!enabled && isOpen())
close();
m_isEnabled = enabled;
}
}
// Check the user defaults and see if the icon database should even be enabled.
- // If not, inform the bridge and bail from init right here
+ // Inform the bridge and, if we're disabled, bail from init right here
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
+ // <rdar://problem/4741419> - IconDatabase should be disabled by default
NSDictionary *initialDefaults = [[NSDictionary alloc] initWithObjectsAndKeys:[NSNumber numberWithBool:YES], WebIconDatabaseEnabledDefaultsKey, nil];
[defaults registerDefaults:initialDefaults];
[initialDefaults release];
- if (![defaults boolForKey:WebIconDatabaseEnabledDefaultsKey]) {
- [_private->databaseBridge _setEnabled:NO];
+ BOOL enabled = [defaults boolForKey:WebIconDatabaseEnabledDefaultsKey];
+ [_private->dataabaseBridge _setEnabled:enabled];
+ if (!enabled)
return self;
- }
// Figure out the directory we should be using for the icon.db
NSString *databaseDirectory = [defaults objectForKey:WebIconDatabaseDirectoryDefaultsKey];