diff options
| author | Allan Sandfeld Jensen <allan.jensen@digia.com> | 2013-09-13 12:51:20 +0200 |
|---|---|---|
| committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-09-19 20:50:05 +0200 |
| commit | d441d6f39bb846989d95bcf5caf387b42414718d (patch) | |
| tree | e367e64a75991c554930278175d403c072de6bb8 /Source/WebKit2/WebProcess/gtk/WebGtkExtensionManager.cpp | |
| parent | 0060b2994c07842f4c59de64b5e3e430525c4b90 (diff) | |
| download | qtwebkit-d441d6f39bb846989d95bcf5caf387b42414718d.tar.gz | |
Import Qt5x2 branch of QtWebkit for Qt 5.2
Importing a new snapshot of webkit.
Change-Id: I2d01ad12cdc8af8cb015387641120a9d7ea5f10c
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@digia.com>
Diffstat (limited to 'Source/WebKit2/WebProcess/gtk/WebGtkExtensionManager.cpp')
| -rw-r--r-- | Source/WebKit2/WebProcess/gtk/WebGtkExtensionManager.cpp | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/Source/WebKit2/WebProcess/gtk/WebGtkExtensionManager.cpp b/Source/WebKit2/WebProcess/gtk/WebGtkExtensionManager.cpp new file mode 100644 index 000000000..ad7ba99fb --- /dev/null +++ b/Source/WebKit2/WebProcess/gtk/WebGtkExtensionManager.cpp @@ -0,0 +1,83 @@ +/* + * Copyright (C) 2012 Igalia S.L. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#include "config.h" +#include "WebGtkExtensionManager.h" + +#include "InjectedBundle.h" +#include "WKBundleAPICast.h" +#include "WKString.h" +#include "WKType.h" +#include "WebKitWebExtensionPrivate.h" +#include <WebCore/FileSystem.h> +#include <wtf/OwnPtr.h> + +namespace WebKit { + +WebGtkExtensionManager& WebGtkExtensionManager::shared() +{ + DEFINE_STATIC_LOCAL(WebGtkExtensionManager, extensionManager, ()); + return extensionManager; +} + +WebGtkExtensionManager::WebGtkExtensionManager() +{ +} + +void WebGtkExtensionManager::scanModules(const String& webExtensionsDirectory, Vector<String>& modules) +{ + Vector<String> modulePaths = WebCore::listDirectory(webExtensionsDirectory, String("*.so")); + for (size_t i = 0; i < modulePaths.size(); ++i) { + if (WebCore::fileExists(modulePaths[i])) + modules.append(modulePaths[i]); + } +} + +void WebGtkExtensionManager::initialize(WKBundleRef bundle, WKTypeRef userData) +{ + m_extension = adoptGRef(webkitWebExtensionCreate(toImpl(bundle))); + + String webExtensionsDirectory; + if (userData) { + ASSERT(WKGetTypeID(userData) == WKStringGetTypeID()); + webExtensionsDirectory = toImpl(static_cast<WKStringRef>(userData))->string(); + } + + if (webExtensionsDirectory.isNull()) + return; + + Vector<String> modulePaths; + scanModules(webExtensionsDirectory, modulePaths); + + for (size_t i = 0; i < modulePaths.size(); ++i) { + OwnPtr<Module> module = adoptPtr(new Module(modulePaths[i])); + if (!module->load()) + continue; + + WebKitWebExtensionInitializeFunction initializeFunction = + module->functionPointer<WebKitWebExtensionInitializeFunction>("webkit_web_extension_initialize"); + if (!initializeFunction) + continue; + + m_extensionModules.append(module.leakPtr()); + initializeFunction(m_extension.get()); + } +} + +} // namespace WebKit |
