~ubuntu-branches/ubuntu/maverick/webkit/maverick

« back to all changes in this revision

Viewing changes to WebCore/bindings/js/kjs_navigator.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Mike Hommey
  • Date: 2007-08-19 15:54:12 UTC
  • Revision ID: james.westby@ubuntu.com-20070819155412-uxxg1h9plpghmtbi
Tags: upstream-0~svn25144
ImportĀ upstreamĀ versionĀ 0~svn25144

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// -*- c-basic-offset: 2 -*-
 
2
/*
 
3
 *  This file is part of the KDE libraries
 
4
 *  Copyright (C) 2000 Harri Porten (porten@kde.org)
 
5
 *  Copyright (c) 2000 Daniel Molkentin (molkentin@kde.org)
 
6
 *  Copyright (c) 2000 Stefan Schimanski (schimmi@kde.org)
 
7
 *  Copyright (C) 2003, 2004, 2005, 2006 Apple Computer, Inc.
 
8
 *
 
9
 *  This library is free software; you can redistribute it and/or
 
10
 *  modify it under the terms of the GNU Lesser General Public
 
11
 *  License as published by the Free Software Foundation; either
 
12
 *  version 2 of the License, or (at your option) any later version.
 
13
 *
 
14
 *  This library is distributed in the hope that it will be useful,
 
15
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
16
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
17
 *  Lesser General Public License for more details.
 
18
 *
 
19
 *  You should have received a copy of the GNU Lesser General Public
 
20
 *  License along with this library; if not, write to the Free Software
 
21
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
22
 */
 
23
 
 
24
#include "config.h"
 
25
#include "kjs_navigator.h"
 
26
 
 
27
#include "AtomicString.h"
 
28
#include "CookieJar.h"
 
29
#include "Document.h"
 
30
#include "Frame.h"
 
31
#include "FrameLoader.h"
 
32
#include "Language.h"
 
33
#include "Page.h"
 
34
#include "PlugInInfoStore.h"
 
35
#include "Settings.h"
 
36
 
 
37
#ifndef WEBCORE_NAVIGATOR_PLATFORM
 
38
#if PLATFORM(MAC) && PLATFORM(PPC)
 
39
#define WEBCORE_NAVIGATOR_PLATFORM "MacPPC"
 
40
#elif PLATFORM(MAC) && PLATFORM(X86)
 
41
#define WEBCORE_NAVIGATOR_PLATFORM "MacIntel"
 
42
#elif PLATFORM(WIN_OS)
 
43
#define WEBCORE_NAVIGATOR_PLATFORM "Win32"
 
44
#else
 
45
#define WEBCORE_NAVIGATOR_PLATFORM ""
 
46
#endif
 
47
#endif // ifndef WEBCORE_NAVIGATOR_PLATFORM
 
48
 
 
49
#ifndef WEBCORE_NAVIGATOR_PRODUCT
 
50
#define WEBCORE_NAVIGATOR_PRODUCT "Gecko"
 
51
#endif // ifndef WEBCORE_NAVIGATOR_PRODUCT
 
52
 
 
53
#ifndef WEBCORE_NAVIGATOR_PRODUCT_SUB
 
54
#define WEBCORE_NAVIGATOR_PRODUCT_SUB "20030107"
 
55
#endif // ifndef WEBCORE_NAVIGATOR_PRODUCT_SUB
 
56
 
 
57
#ifndef WEBCORE_NAVIGATOR_VENDOR
 
58
#define WEBCORE_NAVIGATOR_VENDOR "Apple Computer, Inc."
 
59
#endif // ifndef WEBCORE_NAVIGATOR_VENDOR
 
60
 
 
61
#ifndef WEBCORE_NAVIGATOR_VENDOR_SUB
 
62
#define WEBCORE_NAVIGATOR_VENDOR_SUB ""
 
63
#endif // ifndef WEBCORE_NAVIGATOR_VENDOR_SUB
 
64
 
 
65
using namespace WebCore;
 
66
 
 
67
namespace KJS {
 
68
 
 
69
    class PluginBase : public DOMObject {
 
70
    public:
 
71
        PluginBase(ExecState *exec);
 
72
        virtual ~PluginBase();
 
73
        
 
74
        static void refresh(bool reload);
 
75
 
 
76
    protected:
 
77
        static void cachePluginDataIfNecessary();
 
78
        static Vector<PluginInfo*> *plugins;
 
79
        static Vector<MimeClassInfo*> *mimes;
 
80
 
 
81
    private:
 
82
        static int m_plugInCacheRefCount;
 
83
    };
 
84
 
 
85
 
 
86
    class Plugins : public PluginBase {
 
87
    public:
 
88
        Plugins(ExecState *exec) : PluginBase(exec) {};
 
89
        virtual bool getOwnPropertySlot(ExecState *, const Identifier&, PropertySlot&);
 
90
        JSValue *getValueProperty(ExecState *, int token) const;
 
91
        virtual const ClassInfo* classInfo() const { return &info; }
 
92
        static const ClassInfo info;
 
93
        enum { Length, Refresh };
 
94
    private:
 
95
        static JSValue *indexGetter(ExecState *, JSObject *, const Identifier&, const PropertySlot&);
 
96
        static JSValue *nameGetter(ExecState *, JSObject *, const Identifier&, const PropertySlot&);
 
97
    };
 
98
 
 
99
    class MimeTypes : public PluginBase {
 
100
    public:
 
101
        MimeTypes(ExecState *exec) : PluginBase(exec) { };
 
102
        virtual bool getOwnPropertySlot(ExecState *, const Identifier&, PropertySlot&);
 
103
        JSValue *getValueProperty(ExecState *, int token) const;
 
104
        virtual const ClassInfo* classInfo() const { return &info; }
 
105
        static const ClassInfo info;
 
106
        enum { Length };
 
107
    private:
 
108
        static JSValue *indexGetter(ExecState *, JSObject *, const Identifier&, const PropertySlot&);
 
109
        static JSValue *nameGetter(ExecState *, JSObject *, const Identifier&, const PropertySlot&);
 
110
    };
 
111
 
 
112
    class Plugin : public PluginBase {
 
113
    public:
 
114
        Plugin(ExecState *exec, PluginInfo *info) : PluginBase(exec), m_info(info) { }
 
115
        virtual bool getOwnPropertySlot(ExecState *, const Identifier&, PropertySlot&);
 
116
        JSValue *getValueProperty(ExecState *, int token) const;
 
117
        virtual const ClassInfo* classInfo() const { return &info; }
 
118
        static const ClassInfo info;
 
119
        enum { Name, Filename, Description, Length };
 
120
    private:
 
121
        static JSValue *indexGetter(ExecState *, JSObject *, const Identifier&, const PropertySlot&);
 
122
        static JSValue *nameGetter(ExecState *, JSObject *, const Identifier&, const PropertySlot&);
 
123
 
 
124
        PluginInfo *m_info;
 
125
    };
 
126
 
 
127
    class MimeType : public PluginBase {
 
128
    public:
 
129
        MimeType( ExecState *exec, MimeClassInfo *info ) : PluginBase(exec), m_info(info) { }
 
130
        virtual bool getOwnPropertySlot(ExecState *, const Identifier&, PropertySlot&);
 
131
        JSValue *getValueProperty(ExecState *, int token) const;
 
132
        virtual const ClassInfo* classInfo() const { return &info; }
 
133
        static const ClassInfo info;
 
134
        enum { Type, Suffixes, Description, EnabledPlugin };
 
135
    private:
 
136
        MimeClassInfo *m_info;
 
137
    };
 
138
 
 
139
} // namespace
 
140
 
 
141
#include "kjs_navigator.lut.h"
 
142
 
 
143
namespace KJS {
 
144
 
 
145
const ClassInfo Plugins::info = { "PluginArray", 0, &PluginsTable, 0 };
 
146
const ClassInfo MimeTypes::info = { "MimeTypeArray", 0, &MimeTypesTable, 0 };
 
147
const ClassInfo Plugin::info = { "Plugin", 0, &PluginTable, 0 };
 
148
const ClassInfo MimeType::info = { "MimeType", 0, &MimeTypeTable, 0 };
 
149
 
 
150
Vector<PluginInfo*> *KJS::PluginBase::plugins = 0;
 
151
Vector<MimeClassInfo*> *KJS::PluginBase::mimes = 0;
 
152
int KJS::PluginBase::m_plugInCacheRefCount = 0;
 
153
 
 
154
const ClassInfo Navigator::info = { "Navigator", 0, &NavigatorTable, 0 };
 
155
/*
 
156
@begin NavigatorTable 13
 
157
  appCodeName   Navigator::AppCodeName  DontDelete|ReadOnly
 
158
  appName       Navigator::AppName      DontDelete|ReadOnly
 
159
  appVersion    Navigator::AppVersion   DontDelete|ReadOnly
 
160
  language      Navigator::Language     DontDelete|ReadOnly
 
161
  userAgent     Navigator::UserAgent    DontDelete|ReadOnly
 
162
  platform      Navigator::Platform     DontDelete|ReadOnly
 
163
  plugins       Navigator::_Plugins     DontDelete|ReadOnly
 
164
  mimeTypes     Navigator::_MimeTypes   DontDelete|ReadOnly
 
165
  product       Navigator::Product      DontDelete|ReadOnly
 
166
  productSub    Navigator::ProductSub   DontDelete|ReadOnly
 
167
  vendor        Navigator::Vendor       DontDelete|ReadOnly
 
168
  vendorSub     Navigator::VendorSub    DontDelete|ReadOnly
 
169
  cookieEnabled Navigator::CookieEnabled DontDelete|ReadOnly
 
170
  javaEnabled   Navigator::JavaEnabled  DontDelete|Function 0
 
171
@end
 
172
*/
 
173
KJS_IMPLEMENT_PROTOTYPE_FUNCTION(NavigatorFunc)
 
174
 
 
175
Navigator::Navigator(ExecState *exec, Frame *f) 
 
176
    : m_frame(f)
 
177
{
 
178
    setPrototype(exec->lexicalInterpreter()->builtinObjectPrototype());
 
179
}
 
180
 
 
181
bool Navigator::getOwnPropertySlot(ExecState *exec, const Identifier& propertyName, PropertySlot& slot)
 
182
{
 
183
  return getStaticPropertySlot<NavigatorFunc, Navigator, JSObject>(exec, &NavigatorTable, this, propertyName, slot);
 
184
}
 
185
 
 
186
JSValue* Navigator::getValueProperty(ExecState* exec, int token) const
 
187
{
 
188
  switch (token) {
 
189
  case AppCodeName:
 
190
    return jsString("Mozilla");
 
191
  case AppName:
 
192
    return jsString("Netscape");
 
193
  case AppVersion: {
 
194
    // Version is everything in the user agent string past the "Mozilla/" prefix.
 
195
    const String userAgent = m_frame->loader()->userAgent(m_frame->document() ? m_frame->document()->URL() : KURL());
 
196
    return jsString(userAgent.substring(userAgent.find('/') + 1));
 
197
  }
 
198
  case Product:
 
199
    return jsString(WEBCORE_NAVIGATOR_PRODUCT);
 
200
  case ProductSub:
 
201
    return jsString(WEBCORE_NAVIGATOR_PRODUCT_SUB);
 
202
  case Vendor:
 
203
    return jsString(WEBCORE_NAVIGATOR_VENDOR);
 
204
  case VendorSub:
 
205
    return jsString(WEBCORE_NAVIGATOR_VENDOR_SUB);
 
206
  case Language:
 
207
    return jsString(defaultLanguage());
 
208
  case UserAgent:
 
209
    return jsString(m_frame->loader()->userAgent(m_frame->document() ? m_frame->document()->URL() : KURL()));
 
210
  case Platform:
 
211
    return jsString(WEBCORE_NAVIGATOR_PLATFORM);
 
212
  case _Plugins:
 
213
    return new Plugins(exec);
 
214
  case _MimeTypes:
 
215
    return new MimeTypes(exec);
 
216
  case CookieEnabled:
 
217
    return jsBoolean(cookiesEnabled());
 
218
  }
 
219
  return 0;
 
220
}
 
221
 
 
222
/*******************************************************************/
 
223
 
 
224
void PluginBase::cachePluginDataIfNecessary()
 
225
{
 
226
    if (!plugins) {
 
227
        plugins = new Vector<PluginInfo*>;
 
228
        mimes = new Vector<MimeClassInfo*>;
 
229
        
 
230
        // read configuration
 
231
        PlugInInfoStore c;
 
232
        unsigned pluginCount = c.pluginCount();
 
233
        for (unsigned n = 0; n < pluginCount; n++) {
 
234
            PluginInfo* plugin = c.createPluginInfoForPluginAtIndex(n);
 
235
            if (!plugin) 
 
236
                continue;
 
237
            
 
238
            plugins->append(plugin);
 
239
            if (!plugin->mimes)
 
240
                continue;
 
241
            
 
242
            Vector<MimeClassInfo*>::iterator end = plugin->mimes.end();
 
243
            for (Vector<MimeClassInfo*>::iterator itr = plugin->mimes.begin(); itr != end; itr++)
 
244
                mimes->append(*itr);
 
245
        }
 
246
    }
 
247
}
 
248
 
 
249
PluginBase::PluginBase(ExecState *exec)
 
250
{
 
251
    setPrototype(exec->lexicalInterpreter()->builtinObjectPrototype());
 
252
 
 
253
    cachePluginDataIfNecessary();
 
254
    m_plugInCacheRefCount++;
 
255
}
 
256
 
 
257
PluginBase::~PluginBase()
 
258
{
 
259
    m_plugInCacheRefCount--;
 
260
    if (!m_plugInCacheRefCount) {
 
261
        if (plugins) {
 
262
            deleteAllValues(*plugins);
 
263
            delete plugins;
 
264
            plugins = 0;
 
265
        }
 
266
        if (mimes) {
 
267
            deleteAllValues(*mimes);
 
268
            delete mimes;
 
269
            mimes = 0;
 
270
        }
 
271
    }
 
272
}
 
273
 
 
274
void PluginBase::refresh(bool reload)
 
275
{
 
276
    if (plugins) {
 
277
        deleteAllValues(*plugins);
 
278
        delete plugins;
 
279
        plugins = 0;
 
280
    }
 
281
    if (mimes) {
 
282
        deleteAllValues(*mimes);
 
283
        delete mimes;
 
284
        mimes = 0;
 
285
    }
 
286
    
 
287
    refreshPlugins(reload);
 
288
    cachePluginDataIfNecessary();
 
289
}
 
290
 
 
291
 
 
292
/*******************************************************************/
 
293
 
 
294
/*
 
295
@begin PluginsTable 2
 
296
  length        Plugins::Length         DontDelete|ReadOnly
 
297
  refresh       Plugins::Refresh        DontDelete|Function 0
 
298
@end
 
299
*/
 
300
KJS_IMPLEMENT_PROTOTYPE_FUNCTION(PluginsFunc)
 
301
 
 
302
JSValue *Plugins::getValueProperty(ExecState *exec, int token) const
 
303
{
 
304
  ASSERT(token == Length);
 
305
  return jsNumber(plugins->size());
 
306
}
 
307
 
 
308
JSValue *Plugins::indexGetter(ExecState *exec, JSObject *originalObject, const Identifier& propertyName, const PropertySlot& slot)
 
309
{
 
310
    return new Plugin(exec, plugins->at(slot.index()));
 
311
}
 
312
 
 
313
JSValue *Plugins::nameGetter(ExecState *exec, JSObject *originalObject, const Identifier& propertyName, const PropertySlot& slot)
 
314
{
 
315
    AtomicString atomicPropertyName = propertyName;
 
316
    Vector<PluginInfo*>::iterator end = plugins->end();
 
317
    for (Vector<PluginInfo*>::iterator itr = plugins->begin(); itr != end; itr++) {
 
318
        PluginInfo *pl = *itr;
 
319
        if (pl->name == atomicPropertyName)
 
320
            return new Plugin(exec, pl);
 
321
    }
 
322
    return jsUndefined();
 
323
}
 
324
 
 
325
bool Plugins::getOwnPropertySlot(ExecState *exec, const Identifier& propertyName, PropertySlot& slot)
 
326
{
 
327
    const HashEntry* entry = Lookup::findEntry(&PluginsTable, propertyName);
 
328
    if (entry) {
 
329
      if (entry->attr & Function)
 
330
        slot.setStaticEntry(this, entry, staticFunctionGetter<PluginsFunc>);
 
331
      else
 
332
        slot.setStaticEntry(this, entry, staticValueGetter<Plugins>);
 
333
      return true;
 
334
    } else {
 
335
        // plugins[#]
 
336
        bool ok;
 
337
        unsigned int i = propertyName.toUInt32(&ok);
 
338
        if (ok && i < plugins->size()) {
 
339
            slot.setCustomIndex(this, i, indexGetter);
 
340
            return true;
 
341
        }
 
342
 
 
343
        // plugin[name]
 
344
        AtomicString atomicPropertyName = propertyName;
 
345
        Vector<PluginInfo*>::iterator end = plugins->end();
 
346
        for (Vector<PluginInfo*>::iterator itr = plugins->begin(); itr != end; itr++) {
 
347
            if ((*itr)->name == atomicPropertyName) {
 
348
                slot.setCustom(this, nameGetter);
 
349
                return true;
 
350
            }
 
351
        }
 
352
    }
 
353
 
 
354
    return PluginBase::getOwnPropertySlot(exec, propertyName, slot);
 
355
}
 
356
 
 
357
/*******************************************************************/
 
358
 
 
359
/*
 
360
@begin MimeTypesTable 1
 
361
  length        MimeTypes::Length       DontDelete|ReadOnly
 
362
@end
 
363
*/
 
364
 
 
365
JSValue *MimeTypes::getValueProperty(ExecState *exec, int token) const
 
366
{
 
367
  ASSERT(token == Length);
 
368
  return jsNumber(mimes->size());
 
369
}
 
370
 
 
371
JSValue *MimeTypes::indexGetter(ExecState *exec, JSObject *originalObject, const Identifier& propertyName, const PropertySlot& slot)
 
372
{
 
373
    return new MimeType(exec, mimes->at(slot.index()));
 
374
}
 
375
 
 
376
JSValue *MimeTypes::nameGetter(ExecState *exec, JSObject *originalObject, const Identifier& propertyName, const PropertySlot& slot)
 
377
{
 
378
    AtomicString atomicPropertyName = propertyName;
 
379
    Vector<MimeClassInfo*>::iterator end = mimes->end();
 
380
    for (Vector<MimeClassInfo*>::iterator itr = mimes->begin(); itr != end; itr++) {
 
381
        MimeClassInfo *m = (*itr);
 
382
        if (m->type == atomicPropertyName)
 
383
            return new MimeType(exec, m);
 
384
    }
 
385
    return jsUndefined();
 
386
}
 
387
 
 
388
bool MimeTypes::getOwnPropertySlot(ExecState *exec, const Identifier& propertyName, PropertySlot& slot)
 
389
{
 
390
    const HashEntry* entry = Lookup::findEntry(&MimeTypesTable, propertyName);
 
391
    if (entry) {
 
392
      slot.setStaticEntry(this, entry, staticValueGetter<MimeTypes>);
 
393
      return true;
 
394
    } else {
 
395
        // mimeTypes[#]
 
396
        bool ok;
 
397
        unsigned int i = propertyName.toUInt32(&ok);
 
398
        if (ok && i < mimes->size()) {
 
399
            slot.setCustomIndex(this, i, indexGetter);
 
400
            return true;
 
401
        }
 
402
 
 
403
        // mimeTypes[name]
 
404
        AtomicString atomicPropertyName = propertyName;
 
405
        Vector<MimeClassInfo*>::iterator end = mimes->end();
 
406
        for (Vector<MimeClassInfo*>::iterator itr = mimes->begin(); itr != end; itr++) {
 
407
            if ((*itr)->type == atomicPropertyName) {
 
408
                slot.setCustom(this, nameGetter);
 
409
                return true;
 
410
            }
 
411
        }
 
412
    }
 
413
 
 
414
    return PluginBase::getOwnPropertySlot(exec, propertyName, slot);
 
415
}
 
416
 
 
417
 
 
418
/************************************************************************/
 
419
 
 
420
/*
 
421
@begin PluginTable 4
 
422
  name          Plugin::Name            DontDelete|ReadOnly
 
423
  filename      Plugin::Filename        DontDelete|ReadOnly
 
424
  description   Plugin::Description     DontDelete|ReadOnly
 
425
  length        Plugin::Length          DontDelete|ReadOnly
 
426
@end
 
427
*/
 
428
 
 
429
JSValue *Plugin::getValueProperty(ExecState *exec, int token) const
 
430
{
 
431
    switch (token) {
 
432
    case Name:
 
433
        return jsString(m_info->name);
 
434
    case Filename:
 
435
        return jsString(m_info->file);
 
436
    case Description:
 
437
        return jsString(m_info->desc);
 
438
    case Length: 
 
439
        return jsNumber(m_info->mimes.size());
 
440
    default:
 
441
        ASSERT(0);
 
442
        return jsUndefined();
 
443
    }
 
444
}
 
445
 
 
446
JSValue *Plugin::indexGetter(ExecState *exec, JSObject *originalObject, const Identifier& propertyName, const PropertySlot& slot)
 
447
{
 
448
    Plugin *thisObj = static_cast<Plugin *>(slot.slotBase());
 
449
    return new MimeType(exec, thisObj->m_info->mimes.at(slot.index()));
 
450
}
 
451
 
 
452
JSValue *Plugin::nameGetter(ExecState *exec, JSObject *originalObject, const Identifier& propertyName, const PropertySlot& slot)
 
453
{
 
454
    Plugin *thisObj = static_cast<Plugin *>(slot.slotBase());
 
455
    AtomicString atomicPropertyName = propertyName;
 
456
    Vector<MimeClassInfo*>::iterator end = thisObj->m_info->mimes.end();
 
457
    for (Vector<MimeClassInfo*>::iterator itr = thisObj->m_info->mimes.begin(); itr != end; itr++) {
 
458
        MimeClassInfo *m = (*itr);
 
459
        if (m->type == atomicPropertyName)
 
460
            return new MimeType(exec, m);
 
461
    }
 
462
    return jsUndefined();
 
463
}
 
464
 
 
465
 
 
466
bool Plugin::getOwnPropertySlot(ExecState *exec, const Identifier& propertyName, PropertySlot& slot)
 
467
{
 
468
    const HashEntry* entry = Lookup::findEntry(&PluginTable, propertyName);
 
469
    if (entry) {
 
470
        slot.setStaticEntry(this, entry, staticValueGetter<Plugin>);
 
471
        return true;
 
472
    } else {
 
473
        // plugin[#]
 
474
        bool ok;
 
475
        unsigned int i = propertyName.toUInt32(&ok);
 
476
        if (ok && i < m_info->mimes.size()) {
 
477
            slot.setCustomIndex(this, i, indexGetter);
 
478
            return true;
 
479
        }
 
480
 
 
481
        // plugin["name"]
 
482
        AtomicString atomicPropertyName = propertyName;
 
483
        Vector<MimeClassInfo*>::iterator end = m_info->mimes.end();
 
484
        for (Vector<MimeClassInfo*>::iterator itr = m_info->mimes.begin(); itr != end; itr++) {
 
485
            if ((*itr)->type == atomicPropertyName) {
 
486
                slot.setCustom(this, nameGetter);
 
487
                return true;
 
488
            }
 
489
        }
 
490
    }
 
491
 
 
492
    return PluginBase::getOwnPropertySlot(exec, propertyName, slot);
 
493
}
 
494
 
 
495
/*****************************************************************************/
 
496
 
 
497
/*
 
498
@begin MimeTypeTable 4
 
499
  type          MimeType::Type          DontDelete|ReadOnly
 
500
  suffixes      MimeType::Suffixes      DontDelete|ReadOnly
 
501
  description   MimeType::Description   DontDelete|ReadOnly
 
502
  enabledPlugin MimeType::EnabledPlugin DontDelete|ReadOnly
 
503
@end
 
504
*/
 
505
 
 
506
JSValue *MimeType::getValueProperty(ExecState *exec, int token) const
 
507
{
 
508
    switch (token) {
 
509
    case Type:
 
510
        return jsString(m_info->type);
 
511
    case Suffixes:
 
512
        return jsString(m_info->suffixes);
 
513
    case Description:
 
514
        return jsString(m_info->desc);
 
515
    case EnabledPlugin: {
 
516
        ScriptInterpreter *interpreter = static_cast<ScriptInterpreter *>(exec->dynamicInterpreter());
 
517
        Frame *frame = interpreter->frame();
 
518
        ASSERT(frame);
 
519
        Settings* settings = frame->settings();
 
520
        if (settings && settings->arePluginsEnabled())
 
521
            return new Plugin(exec, m_info->plugin);
 
522
        else
 
523
            return jsUndefined();
 
524
    }
 
525
    default:
 
526
        return jsUndefined();
 
527
    }
 
528
}
 
529
 
 
530
bool MimeType::getOwnPropertySlot(ExecState *exec, const Identifier& propertyName, PropertySlot& slot)
 
531
{
 
532
    return getStaticValueSlot<MimeType, PluginBase>(exec, &MimeTypeTable, this, propertyName, slot);
 
533
}
 
534
 
 
535
JSValue *PluginsFunc::callAsFunction(ExecState *exec, JSObject *, const List &args)
 
536
{
 
537
    PluginBase::refresh(args[0]->toBoolean(exec));
 
538
    return jsUndefined();
 
539
}
 
540
 
 
541
JSValue *NavigatorFunc::callAsFunction(ExecState *exec, JSObject *thisObj, const List &)
 
542
{
 
543
  if (!thisObj->inherits(&KJS::Navigator::info))
 
544
    return throwError(exec, TypeError);
 
545
  Navigator *nav = static_cast<Navigator *>(thisObj);
 
546
  // javaEnabled()
 
547
  Settings* settings = nav->frame() ? nav->frame()->settings() : 0;
 
548
  return jsBoolean(settings && settings->isJavaEnabled());
 
549
}
 
550
 
 
551
} // namespace