Commit 7991caa2 authored by eseidel's avatar eseidel

2006-02-27 Eric Seidel <eseidel@apple.com>

        Reviewed by darin.

        Reworked KConfig and plugin architecture to be much more sane.
        This is part one.  Once this lands, I'll move it under platform with a better name.

        Darin had several great suggested further improvements as part of:
        http://bugzilla.opendarwin.org/show_bug.cgi?id=7451
        I'll make some of those when I move this to platform.

        No layout test possible (no way to control which plugins DRT sees).

        * khtml/ecma/kjs_navigator.cpp:
        (KJS::PluginBase::PluginBase):
        (KJS::PluginBase::~PluginBase):
        (KJS::PluginBase::refresh):
        (KJS::Plugins::getValueProperty):
        (KJS::Plugins::nameGetter):
        (KJS::Plugins::getOwnPropertySlot):
        (KJS::MimeTypes::getValueProperty):
        (KJS::MimeTypes::nameGetter):
        (KJS::MimeTypes::getOwnPropertySlot):
        (KJS::Plugin::getValueProperty):
        (KJS::Plugin::nameGetter):
        (KJS::Plugin::getOwnPropertySlot):
        * khtml/ecma/kjs_navigator.h:
        * khtml/ecma/kjs_window.cpp:
        * kwq/KWQKConfigBase.h:
        (WebCore::PluginInfoStore::PluginInfoStore):
        * kwq/KWQKConfigBase.mm:
        (WebCore::PluginInfoStore::createPluginInfoForPluginAtIndex):
        (WebCore::PluginInfoStore::pluginCount):
        (WebCore::refreshPlugins):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@13014 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 070491d1
2006-02-27 Eric Seidel <eseidel@apple.com>
Reviewed by darin.
Reworked KConfig and plugin architecture to be much more sane.
This is part one. Once this lands, I'll move it under platform with a better name.
Darin had several great suggested further improvements as part of:
http://bugzilla.opendarwin.org/show_bug.cgi?id=7451
I'll make some of those when I move this to platform.
No layout test possible (no way to control which plugins DRT sees).
* khtml/ecma/kjs_navigator.cpp:
(KJS::PluginBase::PluginBase):
(KJS::PluginBase::~PluginBase):
(KJS::PluginBase::refresh):
(KJS::Plugins::getValueProperty):
(KJS::Plugins::nameGetter):
(KJS::Plugins::getOwnPropertySlot):
(KJS::MimeTypes::getValueProperty):
(KJS::MimeTypes::nameGetter):
(KJS::MimeTypes::getOwnPropertySlot):
(KJS::Plugin::getValueProperty):
(KJS::Plugin::nameGetter):
(KJS::Plugin::getOwnPropertySlot):
* khtml/ecma/kjs_navigator.h:
* khtml/ecma/kjs_window.cpp:
* kwq/KWQKConfigBase.h:
(WebCore::PluginInfoStore::PluginInfoStore):
* kwq/KWQKConfigBase.mm:
(WebCore::PluginInfoStore::createPluginInfoForPluginAtIndex):
(WebCore::PluginInfoStore::pluginCount):
(WebCore::refreshPlugins):
2006-02-27 Eric Seidel <eseidel@apple.com>
Reviewed by darin.
......
This diff is collapsed.
......@@ -18,8 +18,8 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef _KJS_NAVIGATOR_H_
#define _KJS_NAVIGATOR_H_
#ifndef KJS_Navigator_H
#define KJS_Navigator_H
#include <kjs/object.h>
......
......@@ -56,6 +56,7 @@
#include <kjs/collector.h>
#include <klocale.h>
#include "FrameTree.h"
#include "khtml_settings.h"
#if KHTML_XSLT
#include "XSLTProcessor.h"
......
......@@ -23,44 +23,43 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef KCONFIG_H_
#define KCONFIG_H_
#ifndef PluginConfig_H
#define PluginConfig_H
#include "QString.h"
#include "KWQKHTMLSettings.h"
class QStringList;
class KWQKConfigImpl;
#include "PlatformString.h"
#include <kxmlcore/Vector.h>
namespace WebCore {
class Color;
}
class KConfig {
public:
KConfig(const QString &n, bool bReadOnly=false, bool bUseKDEGlobals = true);
~KConfig();
struct PluginInfo;
void setGroup(const QString &pGroup);
QString readEntry(const char *pKey, const QString& aDefault=QString::null) const;
int readNumEntry(const char *pKey, int nDefault=0) const;
unsigned int readUnsignedNumEntry(const KHTMLSettings *settings, const char *pKey, unsigned int nDefault=0) const;
WebCore::Color readColorEntry(const char *pKey, const WebCore::Color *pDefault=0L) const;
struct MimeClassInfo {
String type;
String desc;
String suffixes;
PluginInfo* plugin;
};
private:
struct PluginInfo {
String name;
String file;
String desc;
Vector<MimeClassInfo*> mimes;
};
KConfig(const KConfig &);
KConfig &operator=(const KConfig &);
class PluginInfoStore {
public:
PluginInfoStore() { }
PluginInfo *createPluginInfoForPluginAtIndex(unsigned);
unsigned pluginCount() const;
KWQKConfigImpl *impl;
private:
PluginInfoStore(const PluginInfoStore&);
PluginInfoStore &operator=(const PluginInfoStore&);
};
void RefreshPlugins(bool reload);
void refreshPlugins(bool reload);
}
#endif
......@@ -26,126 +26,60 @@
#include "config.h"
#import "KWQKConfigBase.h"
#import "Color.h"
#import "KWQExceptions.h"
#import "KWQKHTMLSettings.h"
#import "KWQLogging.h"
#import "QStringList.h"
#import "WebCoreSettings.h"
#import "WebCoreViewFactory.h"
class KWQKConfigImpl
{
public:
bool isPluginInfo;
bool isKonquerorRC;
int pluginIndex;
};
namespace WebCore {
KConfig::KConfig(const QString &n, bool bReadOnly, bool bUseKDEGlobals)
PluginInfo *PluginInfoStore::createPluginInfoForPluginAtIndex(unsigned index)
{
impl = new KWQKConfigImpl;
impl->isPluginInfo = n.contains("pluginsinfo");
impl->isKonquerorRC = (n == "konquerorrc");
impl->pluginIndex = 0;
}
KConfig::~KConfig()
{
delete impl;
}
void KConfig::setGroup(const QString &pGroup)
{
if (impl->isPluginInfo) {
impl->pluginIndex = pGroup.toUInt();
}
}
QString KConfig::readEntry(const char *pKey, const QString& aDefault) const
{
if (impl->isPluginInfo) {
KWQ_BLOCK_EXCEPTIONS;
NSString *result = nil;
id <WebCorePluginInfo> plugin = [[[WebCoreViewFactory sharedFactory] pluginsInfo] objectAtIndex:impl->pluginIndex];
if (strcmp(pKey, "name") == 0) {
result = [plugin name];
} else if (strcmp(pKey, "file") == 0) {
result = [plugin filename];
} else if (strcmp(pKey, "description") == 0) {
result = [plugin pluginDescription];
} else if (strcmp(pKey, "mime") == 0) {
NSEnumerator *MIMETypeEnumerator = [plugin MIMETypeEnumerator], *extensionEnumerator;
NSMutableString *MIMEString = [NSMutableString string];
NSString *MIME, *extension;
NSArray *extensions;
while ((MIME = [MIMETypeEnumerator nextObject]) != nil) {
[MIMEString appendFormat:@"%@:", MIME];
extensions = [plugin extensionsForMIMEType:MIME];
extensionEnumerator = [extensions objectEnumerator];
while ((extension = [extensionEnumerator nextObject]) != nil) {
[MIMEString appendFormat:@"%@,", extension];
}
// Delete the last ",".
NSRange tempRange = { [MIMEString length]-1, 1 }; // workaround for 4213314
[MIMEString deleteCharactersInRange:tempRange];
[MIMEString appendFormat:@":%@;", [plugin descriptionForMIMEType:MIME]];
}
result = MIMEString;
}
return QString::fromNSString(result);
KWQ_UNBLOCK_EXCEPTIONS;
PluginInfo *pluginInfo = new PluginInfo;
KWQ_BLOCK_EXCEPTIONS;
return QString();
id <WebCorePluginInfo> plugin = [[[WebCoreViewFactory sharedFactory] pluginsInfo] objectAtIndex:index];
pluginInfo->name = [plugin name];
pluginInfo->file = [plugin filename];
pluginInfo->desc = [plugin pluginDescription];
NSEnumerator *MIMETypeEnumerator = [plugin MIMETypeEnumerator];
while (NSString *MIME = [MIMETypeEnumerator nextObject]) {
MimeClassInfo *mime = new MimeClassInfo;
pluginInfo->mimes.append(mime);
mime->type = String(MIME).lower();
mime->suffixes = [[plugin extensionsForMIMEType:MIME] componentsJoinedByString:@","];
mime->desc = [plugin descriptionForMIMEType:MIME];
mime->plugin = pluginInfo;
}
LOG_ERROR("config %s not implemented", pKey);
return QString();
}
return pluginInfo;
int KConfig::readNumEntry(const char *pKey, int nDefault) const
{
if (impl->isPluginInfo && strcmp(pKey, "number") == 0) {
KWQ_BLOCK_EXCEPTIONS;
return [[[WebCoreViewFactory sharedFactory] pluginsInfo] count];
KWQ_UNBLOCK_EXCEPTIONS;
return 0;
}
LOG_ERROR("config %s not implemented", pKey);
return nDefault;
}
KWQ_UNBLOCK_EXCEPTIONS;
if (pluginInfo && pluginInfo->mimes)
deleteAllValues(pluginInfo->mimes);
delete pluginInfo;
unsigned KConfig::readUnsignedNumEntry(const KHTMLSettings *settings, const char *pKey, unsigned nDefault) const
{
if (impl->isKonquerorRC && strcmp(pKey, "WindowOpenPolicy") == 0) {
if (settings->JavaScriptCanOpenWindowsAutomatically()) {
return 0;
} else {
return 3;
}
}
LOG_ERROR("config %s not implemented", pKey);
return nDefault;
return 0;
}
Color KConfig::readColorEntry(const char *pKey, const Color *pDefault) const
unsigned PluginInfoStore::pluginCount() const
{
return pDefault ? *pDefault : Color(0, 0, 0);
KWQ_BLOCK_EXCEPTIONS;
return [[[WebCoreViewFactory sharedFactory] pluginsInfo] count];
KWQ_UNBLOCK_EXCEPTIONS;
return 0;
}
void RefreshPlugins(bool reload)
void refreshPlugins(bool reload)
{
KWQ_BLOCK_EXCEPTIONS;
[[WebCoreViewFactory sharedFactory] refreshPlugins:reload];
KWQ_UNBLOCK_EXCEPTIONS;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment