Unreviewed, rebaseline inspector/styles/region-style-crash.html after r131176.
[WebKit.git] / Source / WebKit2 / UIProcess / efl / WebInspectorProxyEfl.cpp
1 /*
2  * Copyright (C) 2012 Samsung Electronics
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  * 1. Redistributions of source code must retain the above copyright
8  *    notice, this list of conditions and the following disclaimer.
9  * 2. Redistributions in binary form must reproduce the above copyright
10  *    notice, this list of conditions and the following disclaimer in the
11  *    documentation and/or other materials provided with the distribution.
12  *
13  * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23  * THE POSSIBILITY OF SUCH DAMAGE.
24  */
25
26 #include "config.h"
27 #include "WebInspectorProxy.h"
28
29 #if ENABLE(INSPECTOR)
30
31 #include "WebProcessProxy.h"
32 #include "ewk_settings.h"
33 #include "ewk_view.h"
34 #include "ewk_view_private.h"
35 #include <WebCore/NotImplemented.h>
36 #include <unistd.h>
37 #include <wtf/text/CString.h>
38 #include <wtf/text/WTFString.h>
39
40 namespace WebKit {
41
42 static void resizeInspectorWindow(Ecore_Evas* inspectorWindow)
43 {
44     Evas_Object* inspectorView = evas_object_name_find(ecore_evas_get(inspectorWindow), "inspector");
45     if (!inspectorView)
46         return;
47
48     int width, height;
49     ecore_evas_geometry_get(inspectorWindow, 0, 0, &width, &height);
50
51     evas_object_move(inspectorView, 0, 0);
52     evas_object_resize(inspectorView, width, height);
53 }
54
55 static void destroyInspectorWindow(Ecore_Evas* inspectorWindow)
56 {
57     Evas_Object* inspectorView = evas_object_name_find(ecore_evas_get(inspectorWindow), "inspector");
58     if (inspectorView)
59         evas_object_smart_callback_call(inspectorView, "inspector,view,close", 0);
60 }
61
62 static void closeInspectorWindow(void* userData, Evas_Object*, void*)
63 {
64     WebInspectorProxy* inspectorProxy = static_cast<WebInspectorProxy*>(userData);
65
66     inspectorProxy->close();
67 }
68
69 void WebInspectorProxy::createInspectorWindow()
70 {
71     ecore_evas_title_set(m_inspectorWindow, "Web Inspector");
72     ecore_evas_callback_resize_set(m_inspectorWindow, resizeInspectorWindow);
73     ecore_evas_callback_delete_request_set(m_inspectorWindow, destroyInspectorWindow);
74     ecore_evas_show(m_inspectorWindow);
75
76     evas_object_name_set(m_inspectorView, "inspector");
77     evas_object_move(m_inspectorView, 0, 0);
78     evas_object_resize(m_inspectorView, initialWindowWidth, initialWindowHeight);
79     evas_object_show(m_inspectorView);
80
81     evas_object_focus_set(m_inspectorView, true);
82 }
83
84 WebPageProxy* WebInspectorProxy::platformCreateInspectorPage()
85 {
86     ASSERT(m_page);
87
88     m_inspectorWindow = ecore_evas_new(0, 0, 0, initialWindowWidth, initialWindowHeight, 0);
89     if (!m_inspectorWindow)
90         return 0;
91
92     m_inspectorView = ewk_view_base_add(ecore_evas_get(m_inspectorWindow), toAPI(page()->process()->context()), toAPI(inspectorPageGroup()));
93     ewk_view_theme_set(m_inspectorView, TEST_THEME_DIR"/default.edj");
94
95     Ewk_Settings* settings = ewk_view_settings_get(m_inspectorView);
96     ewk_settings_file_access_from_file_urls_allowed_set(settings, true);
97
98     return ewk_view_page_get(m_inspectorView);
99 }
100
101 void WebInspectorProxy::platformOpen()
102 {
103     if (m_isAttached)
104         platformAttach();
105     else
106         createInspectorWindow();
107
108     evas_object_smart_callback_add(m_inspectorView, "inspector,view,close", closeInspectorWindow, this);
109 }
110
111 void WebInspectorProxy::platformDidClose()
112 {
113     if (m_inspectorView) {
114         evas_object_del(m_inspectorView);
115         m_inspectorView = 0;
116     }
117
118     if (m_inspectorWindow) {
119         ecore_evas_free(m_inspectorWindow);
120         m_inspectorWindow = 0;
121     }
122 }
123
124 void WebInspectorProxy::platformBringToFront()
125 {
126     notImplemented();
127 }
128
129 bool WebInspectorProxy::platformIsFront()
130 {
131     notImplemented();
132     return false;
133 }
134
135 void WebInspectorProxy::platformInspectedURLChanged(const String&)
136 {
137     notImplemented();
138 }
139
140 String WebInspectorProxy::inspectorPageURL() const
141 {
142     return makeString(inspectorBaseURL(), "/inspector.html");
143 }
144
145 String WebInspectorProxy::inspectorBaseURL() const
146 {
147     String inspectorFilesPath = makeString("file://", WK2_WEB_INSPECTOR_INSTALL_DIR);
148     if (access(inspectorFilesPath.utf8().data(), R_OK))
149         inspectorFilesPath = makeString("file://", WK2_WEB_INSPECTOR_DIR);
150
151     return inspectorFilesPath;
152 }
153
154 unsigned WebInspectorProxy::platformInspectedWindowHeight()
155 {
156     notImplemented();
157     return 0;
158 }
159
160 void WebInspectorProxy::platformAttach()
161 {
162     notImplemented();
163 }
164
165 void WebInspectorProxy::platformDetach()
166 {
167     notImplemented();
168 }
169
170 void WebInspectorProxy::platformSetAttachedWindowHeight(unsigned)
171 {
172     notImplemented();
173 }
174
175 } // namespace WebKit
176
177 #endif // ENABLE(INSPECTOR)