Changeset 48112 in webkit
- Timestamp:
- Sep 7, 2009 7:15:06 AM (15 years ago)
- Location:
- trunk/WebKit/qt
- Files:
-
- 1 deleted
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebKit/qt/Api/qwebplugindatabase.cpp
r46975 r48112 20 20 #include "config.h" 21 21 #include "qwebplugindatabase.h" 22 #include "qwebplugindatabase_p.h"23 22 24 23 #include "PluginDatabase.h" … … 32 31 \brief Represents a single MIME type supported by a plugin. 33 32 */ 34 35 QWebPluginInfoPrivate::QWebPluginInfoPrivate(RefPtr<PluginPackage> pluginPackage)36 : plugin(pluginPackage)37 {38 }39 40 QWebPluginDatabasePrivate::QWebPluginDatabasePrivate(PluginDatabase* pluginDatabase)41 : database(pluginDatabase)42 {43 }44 33 45 34 /*! … … 65 54 */ 66 55 QWebPluginInfo::QWebPluginInfo() 67 : d(new QWebPluginInfoPrivate(0)) 68 { 69 } 70 71 QWebPluginInfo::QWebPluginInfo(PluginPackage* plugin) 72 : d(new QWebPluginInfoPrivate(plugin)) 73 { 56 : m_package(0) 57 { 58 } 59 60 QWebPluginInfo::QWebPluginInfo(PluginPackage* package) 61 : m_package(package) 62 { 63 if (m_package) 64 m_package->ref(); 74 65 } 75 66 … … 78 69 */ 79 70 QWebPluginInfo::QWebPluginInfo(const QWebPluginInfo& other) 80 : d(new QWebPluginInfoPrivate(other.d->plugin)) 81 { 71 : m_package(other.m_package) 72 { 73 if (m_package) 74 m_package->ref(); 82 75 } 83 76 … … 87 80 QWebPluginInfo::~QWebPluginInfo() 88 81 { 89 delete d; 82 if (m_package) 83 m_package->deref(); 90 84 } 91 85 … … 97 91 QString QWebPluginInfo::name() const 98 92 { 99 if (! d->plugin)93 if (!m_package) 100 94 return QString(); 101 return d->plugin->name();95 return m_package->name(); 102 96 } 103 97 … … 109 103 QString QWebPluginInfo::description() const 110 104 { 111 if (! d->plugin)105 if (!m_package) 112 106 return QString(); 113 return d->plugin->description();107 return m_package->description(); 114 108 } 115 109 … … 121 115 QList<QWebPluginInfo::MimeType> QWebPluginInfo::mimeTypes() const 122 116 { 123 if (! d->plugin)117 if (!m_package) 124 118 return QList<MimeType>(); 125 119 126 120 QList<MimeType> mimeTypes; 127 const MIMEToDescriptionsMap& mimeToDescriptions = d->plugin->mimeToDescriptions();121 const MIMEToDescriptionsMap& mimeToDescriptions = m_package->mimeToDescriptions(); 128 122 MIMEToDescriptionsMap::const_iterator end = mimeToDescriptions.end(); 129 123 for (MIMEToDescriptionsMap::const_iterator it = mimeToDescriptions.begin(); it != end; ++it) { … … 133 127 134 128 QStringList fileExtensions; 135 Vector<String> extensions = d->plugin->mimeToExtensions().get(mimeType.name);129 Vector<String> extensions = m_package->mimeToExtensions().get(mimeType.name); 136 130 137 131 for (unsigned i = 0; i < extensions.size(); ++i) … … 167 161 QString QWebPluginInfo::path() const 168 162 { 169 if (! d->plugin)163 if (!m_package) 170 164 return QString(); 171 return d->plugin->path();165 return m_package->path(); 172 166 } 173 167 … … 177 171 bool QWebPluginInfo::isNull() const 178 172 { 179 return ! d->plugin;173 return !m_package; 180 174 } 181 175 … … 190 184 void QWebPluginInfo::setEnabled(bool enabled) 191 185 { 192 if (! d->plugin)186 if (!m_package) 193 187 return; 194 d->plugin->setEnabled(enabled);188 m_package->setEnabled(enabled); 195 189 } 196 190 … … 202 196 bool QWebPluginInfo::isEnabled() const 203 197 { 204 if (! d->plugin)198 if (!m_package) 205 199 return false; 206 return d->plugin->isEnabled();200 return m_package->isEnabled(); 207 201 } 208 202 209 203 bool QWebPluginInfo::operator==(const QWebPluginInfo& other) const 210 204 { 211 return d->plugin == other.d->plugin;205 return m_package == other.m_package; 212 206 } 213 207 214 208 bool QWebPluginInfo::operator!=(const QWebPluginInfo& other) const 215 209 { 216 return d->plugin != other.d->plugin;210 return m_package != other.m_package; 217 211 } 218 212 … … 222 216 return *this; 223 217 224 d->plugin = other.d->plugin; 218 if (m_package) 219 m_package->deref(); 220 m_package = other.m_package; 221 if (m_package) 222 m_package->ref(); 223 225 224 return *this; 226 225 } … … 254 253 QWebPluginDatabase::QWebPluginDatabase(QObject* parent) 255 254 : QObject(parent) 256 , d(new QWebPluginDatabasePrivate(PluginDatabase::installedPlugins()))255 , m_database(PluginDatabase::installedPlugins()) 257 256 { 258 257 } … … 260 259 QWebPluginDatabase::~QWebPluginDatabase() 261 260 { 262 delete d;263 261 } 264 262 … … 274 272 { 275 273 QList<QWebPluginInfo> qwebplugins; 276 const Vector<PluginPackage*>& plugins = d->database->plugins();274 const Vector<PluginPackage*>& plugins = m_database->plugins(); 277 275 278 276 for (unsigned int i = 0; i < plugins.size(); ++i) { … … 309 307 QStringList paths; 310 308 311 const Vector<String>& directories = d->database->pluginDirectories();309 const Vector<String>& directories = m_database->pluginDirectories(); 312 310 for (unsigned int i = 0; i < directories.size(); ++i) 313 311 paths.append(directories[i]); … … 329 327 directories.append(paths.at(i)); 330 328 331 d->database->setPluginDirectories(directories);329 m_database->setPluginDirectories(directories); 332 330 // PluginDatabase::setPluginDirectories() does not refresh the database. 333 d->database->refresh();331 m_database->refresh(); 334 332 } 335 333 … … 342 340 void QWebPluginDatabase::addSearchPath(const QString& path) 343 341 { 344 d->database->addExtraPluginDirectory(path);342 m_database->addExtraPluginDirectory(path); 345 343 // PluginDatabase::addExtraPluginDirectory() does refresh the database. 346 344 } … … 356 354 void QWebPluginDatabase::refresh() 357 355 { 358 d->database->refresh();356 m_database->refresh(); 359 357 } 360 358 … … 366 364 QWebPluginInfo QWebPluginDatabase::pluginForMimeType(const QString& mimeType) 367 365 { 368 return QWebPluginInfo( d->database->pluginForMIMEType(mimeType));366 return QWebPluginInfo(m_database->pluginForMIMEType(mimeType)); 369 367 } 370 368 … … 379 377 void QWebPluginDatabase::setPreferredPluginForMimeType(const QString& mimeType, const QWebPluginInfo& plugin) 380 378 { 381 d->database->setPreferredPluginForMIMEType(mimeType, plugin.d->plugin.get());382 } 379 m_database->setPreferredPluginForMIMEType(mimeType, plugin.m_package); 380 } -
trunk/WebKit/qt/Api/qwebplugindatabase.h
r46764 r48112 28 28 29 29 namespace WebCore { 30 class PluginDatabase; 30 31 class PluginPackage; 31 32 } … … 40 41 41 42 private: 42 QWebPluginInfo(WebCore::PluginPackage* p lugin);43 QWebPluginInfo(WebCore::PluginPackage* package); 43 44 44 45 public: … … 62 63 63 64 private: 64 QWebPluginInfoPrivate *d; 65 QWebPluginInfoPrivate* d; 66 WebCore::PluginPackage* m_package; 65 67 }; 66 68 … … 89 91 90 92 private: 91 QWebPluginDatabasePrivate *d; 93 QWebPluginDatabasePrivate* d; 94 WebCore::PluginDatabase* m_database; 92 95 }; 93 96 -
trunk/WebKit/qt/ChangeLog
r48097 r48112 1 2009-09-07 Jakub Wieczorek <faw217@gmail.com> 2 3 Reviewed by Simon Hausmann. 4 5 Remove the private classes from QWebPluginDatabase. 6 https://bugs.webkit.org/show_bug.cgi?id=27651 7 8 Instead, hold the PluginDatabase and PluginPackage objects as class 9 members and take care of refcounting on our own instead of using RefPtr. 10 11 This way we not only made the code cleaner but also got rid of 12 redundant allocations when constructing null QWebPluginInfo objects. 13 14 The private classes have been forward-declared and the d-pointers left 15 to be on the safe side. 16 17 * Api/qwebplugindatabase.cpp: 18 (QWebPluginInfo::QWebPluginInfo): 19 (QWebPluginInfo::~QWebPluginInfo): 20 (QWebPluginInfo::name): 21 (QWebPluginInfo::description): 22 (QWebPluginInfo::mimeTypes): 23 (QWebPluginInfo::path): 24 (QWebPluginInfo::isNull): 25 (QWebPluginInfo::setEnabled): 26 (QWebPluginInfo::isEnabled): 27 (QWebPluginInfo::operator==): 28 (QWebPluginInfo::operator!=): 29 (QWebPluginInfo::operator=): 30 (QWebPluginDatabase::QWebPluginDatabase): 31 (QWebPluginDatabase::~QWebPluginDatabase): 32 (QWebPluginDatabase::plugins): 33 (QWebPluginDatabase::searchPaths): 34 (QWebPluginDatabase::setSearchPaths): 35 (QWebPluginDatabase::addSearchPath): 36 (QWebPluginDatabase::refresh): 37 (QWebPluginDatabase::pluginForMimeType): 38 (QWebPluginDatabase::setPreferredPluginForMimeType): 39 * Api/qwebplugindatabase.h: 40 * Api/qwebplugindatabase_p.h: Removed. 41 1 42 2009-09-05 Jakub Wieczorek <faw217@gmail.com> 2 43
Note: See TracChangeset
for help on using the changeset viewer.