WebInspectorProxyEfl.cpp [plain text]
#include "config.h"
#include "WebInspectorProxy.h"
#if ENABLE(INSPECTOR)
#include "EwkView.h"
#include "WebProcessProxy.h"
#include "ewk_context_private.h"
#include "ewk_page_group_private.h"
#include "ewk_settings.h"
#include "ewk_view.h"
#include "ewk_view_private.h"
#include <WebCore/EflInspectorUtilities.h>
#include <WebCore/NotImplemented.h>
#include <WebKit/WKPage.h>
#include <WebKit/WKPageGroup.h>
#include <WebKit/WKString.h>
#include <WebKit/WKViewEfl.h>
#include <wtf/text/CString.h>
#include <wtf/text/StringBuilder.h>
#include <wtf/text/WTFString.h>
namespace WebKit {
static void resizeInspectorWindow(Ecore_Evas* inspectorWindow)
{
Evas_Object* inspectorView = evas_object_name_find(ecore_evas_get(inspectorWindow), "inspector");
if (!inspectorView)
return;
int width, height;
ecore_evas_geometry_get(inspectorWindow, 0, 0, &width, &height);
evas_object_move(inspectorView, 0, 0);
evas_object_resize(inspectorView, width, height);
}
static void destroyInspectorWindow(Ecore_Evas* inspectorWindow)
{
Evas_Object* inspectorView = evas_object_name_find(ecore_evas_get(inspectorWindow), "inspector");
if (inspectorView)
evas_object_smart_callback_call(inspectorView, "inspector,view,close", 0);
}
static void closeInspectorWindow(void* userData, Evas_Object*, void*)
{
WebInspectorProxy* inspectorProxy = static_cast<WebInspectorProxy*>(userData);
inspectorProxy->close();
}
void WebInspectorProxy::createInspectorWindow()
{
ecore_evas_title_set(m_inspectorWindow, "Web Inspector");
ecore_evas_callback_resize_set(m_inspectorWindow, resizeInspectorWindow);
ecore_evas_callback_delete_request_set(m_inspectorWindow, destroyInspectorWindow);
ecore_evas_show(m_inspectorWindow);
evas_object_name_set(m_inspectorView, "inspector");
evas_object_move(m_inspectorView, 0, 0);
evas_object_resize(m_inspectorView, initialWindowWidth, initialWindowHeight);
evas_object_show(m_inspectorView);
evas_object_focus_set(m_inspectorView, true);
}
WebPageProxy* WebInspectorProxy::platformCreateInspectorPage()
{
ASSERT(m_page);
#ifdef HAVE_ECORE_X
const char* engine = "opengl_x11";
m_inspectorWindow = ecore_evas_new(engine, 0, 0, initialWindowWidth, initialWindowHeight, 0);
if (!m_inspectorWindow)
#endif
m_inspectorWindow = ecore_evas_new(0, 0, 0, initialWindowWidth, initialWindowHeight, 0);
if (!m_inspectorWindow)
return 0;
WKContextRef wkContext = toAPI(&page()->process().context());
WKPageGroupRef wkPageGroup = toAPI(inspectorPageGroup());
m_inspectorView = EWKViewCreate(wkContext, wkPageGroup, ecore_evas_get(m_inspectorWindow), 0);
WKViewRef wkView = EWKViewGetWKView(m_inspectorView);
WKRetainPtr<WKStringRef> wkTheme = adoptWK(WKStringCreateWithUTF8CString(TEST_THEME_DIR "/default.edj"));
WKViewSetThemePath(wkView, wkTheme.get());
WKPreferencesRef wkPreferences = WKPageGroupGetPreferences(wkPageGroup);
WKPreferencesSetFileAccessFromFileURLsAllowed(wkPreferences, true);
return toImpl(WKViewGetPage(wkView));
}
void WebInspectorProxy::platformOpen()
{
if (m_isAttached)
platformAttach();
else
createInspectorWindow();
evas_object_smart_callback_add(m_inspectorView, "inspector,view,close", closeInspectorWindow, this);
}
void WebInspectorProxy::platformDidClose()
{
if (m_inspectorView) {
evas_object_del(m_inspectorView);
m_inspectorView = 0;
}
if (m_inspectorWindow) {
ecore_evas_free(m_inspectorWindow);
m_inspectorWindow = 0;
}
}
void WebInspectorProxy::platformHide()
{
notImplemented();
}
void WebInspectorProxy::platformBringToFront()
{
notImplemented();
}
bool WebInspectorProxy::platformIsFront()
{
notImplemented();
return false;
}
void WebInspectorProxy::platformInspectedURLChanged(const String& url)
{
if (!m_inspectorWindow)
return;
String title = "WebInspector - " + url;
ecore_evas_title_set(m_inspectorWindow, title.utf8().data());
}
String WebInspectorProxy::inspectorPageURL() const
{
StringBuilder builder;
builder.append(inspectorBaseURL());
builder.appendLiteral("/Main.html");
return builder.toString();
}
String WebInspectorProxy::inspectorTestPageURL() const
{
StringBuilder builder;
builder.append(inspectorBaseURL());
builder.appendLiteral("/Test.html");
return builder.toString();
}
String WebInspectorProxy::inspectorBaseURL() const
{
return "file://" + WebCore::inspectorResourcePath();
}
unsigned WebInspectorProxy::platformInspectedWindowHeight()
{
notImplemented();
return 0;
}
unsigned WebInspectorProxy::platformInspectedWindowWidth()
{
notImplemented();
return 0;
}
void WebInspectorProxy::platformAttach()
{
notImplemented();
}
void WebInspectorProxy::platformDetach()
{
notImplemented();
}
void WebInspectorProxy::platformSetAttachedWindowHeight(unsigned)
{
notImplemented();
}
void WebInspectorProxy::platformSetAttachedWindowWidth(unsigned)
{
notImplemented();
}
void WebInspectorProxy::platformSetToolbarHeight(unsigned)
{
notImplemented();
}
void WebInspectorProxy::platformSave(const String&, const String&, bool, bool)
{
notImplemented();
}
void WebInspectorProxy::platformAppend(const String&, const String&)
{
notImplemented();
}
void WebInspectorProxy::platformAttachAvailabilityChanged(bool)
{
notImplemented();
}
}
#endif // ENABLE(INSPECTOR)