| Differences between
and this patch
- a/Source/WebKit2/ChangeLog +41 lines
Lines 1-3 a/Source/WebKit2/ChangeLog_sec1
1
2012-11-04  Christophe Dumez  <christophe.dumez@intel.com>
2
3
        [EFL][WK2] The icon database path should be set by the client
4
        https://bugs.webkit.org/show_bug.cgi?id=101182
5
6
        Reviewed by NOBODY (OOPS!).
7
8
        No longer set the favicon database path in database instance getter.
9
        Instead, a new ewk_context_favicon_database_directory_set() API
10
        function was added to let the client set the icon database path.
11
        This is needed because the icon database path can only be set once
12
        and setting it unconditionally in the getter prevents the client
13
        from setting it.
14
15
        This will also avoid crashes in WebKitTestRunner since WKTR was
16
        setting the path once and ewk_context was attempting to override it.
17
18
        Note that the favicon database functionality is disabled until the
19
        client sets its path.
20
21
        * UIProcess/API/efl/ewk_context.cpp:
22
        (Ewk_Context::ensureFaviconDatabase):
23
        (Ewk_Context::setFaviconDatabaseDirectoryPath):
24
        (Ewk_Context::faviconDatabase):
25
        (ewk_context_favicon_database_directory_set):
26
        * UIProcess/API/efl/ewk_context.h:
27
        * UIProcess/API/efl/ewk_context_private.h:
28
        (Ewk_Context):
29
        * UIProcess/API/efl/ewk_favicon_database.cpp:
30
        (Ewk_Favicon_Database::Ewk_Favicon_Database):
31
        (Ewk_Favicon_Database::~Ewk_Favicon_Database):
32
        (Ewk_Favicon_Database::iconURLForPageURL):
33
        (Ewk_Favicon_Database::iconForPageURL):
34
        (Ewk_Favicon_Database::getIconSurfaceSynchronously):
35
        * UIProcess/API/efl/ewk_favicon_database_private.h:
36
        (WebKit):
37
        (Ewk_Favicon_Database::create):
38
        (Ewk_Favicon_Database):
39
        * UIProcess/API/efl/tests/test_ewk2_favicon_database.cpp:
40
        (TEST_F):
41
1
2012-11-04  Halton Huo  <halton.huo@intel.com>
42
2012-11-04  Halton Huo  <halton.huo@intel.com>
2
43
3
        [EFL] Use _LIBRARIES instead of _LIBRARY
44
        [EFL] Use _LIBRARIES instead of _LIBRARY
- a/Source/WebKit2/UIProcess/API/efl/ewk_context.cpp -9 / +35 lines
Lines 145-161 Ewk_Cookie_Manager* Ewk_Context::cookieManager() a/Source/WebKit2/UIProcess/API/efl/ewk_context.cpp_sec1
145
    return m_cookieManager.get();
145
    return m_cookieManager.get();
146
}
146
}
147
147
148
void Ewk_Context::ensureFaviconDatabase()
149
{
150
    if (m_faviconDatabase)
151
        return;
152
153
    m_faviconDatabase = Ewk_Favicon_Database::create(toImpl(m_context.get())->iconDatabase());
154
}
155
156
bool Ewk_Context::setFaviconDatabaseDirectoryPath(const String& databaseDirectory)
157
{
158
    ensureFaviconDatabase();
159
160
    WebContext* webContext = toImpl(m_context.get());
161
162
    // The database path is already open so its path was
163
    // already set.
164
    if (webContext->iconDatabase()->isOpen())
165
        return false;
166
167
    // If databaseDirectory is empty, we use the default database path for the platform.
168
    String databasePath = databaseDirectory.isEmpty() ? webContext->iconDatabasePath() : pathByAppendingComponent(databaseDirectory, WebCore::IconDatabase::defaultDatabaseFilename());
169
    webContext->setIconDatabasePath(databasePath);
170
171
    return true;
172
}
173
148
Ewk_Favicon_Database* Ewk_Context::faviconDatabase()
174
Ewk_Favicon_Database* Ewk_Context::faviconDatabase()
149
{
175
{
150
    if (!m_faviconDatabase) {
176
    ensureFaviconDatabase();
151
        WKRetainPtr<WKIconDatabaseRef> iconDatabase = WKContextGetIconDatabase(m_context.get());
177
    ASSERT(m_faviconDatabase);
152
        // Set the database path if it is not open yet.
153
        if (!toImpl(iconDatabase.get())->isOpen()) {
154
            WebContext* webContext = toImpl(m_context.get());
155
            webContext->setIconDatabasePath(webContext->iconDatabasePath());
156
        }
157
        m_faviconDatabase = Ewk_Favicon_Database::create(iconDatabase.get());
158
    }
159
178
160
    return m_faviconDatabase.get();
179
    return m_faviconDatabase.get();
161
}
180
}
Lines 215-220 Ewk_Cookie_Manager* ewk_context_cookie_manager_get(const Ewk_Context* ewkContext a/Source/WebKit2/UIProcess/API/efl/ewk_context.cpp_sec2
215
    return const_cast<Ewk_Context*>(ewkContext)->cookieManager();
234
    return const_cast<Ewk_Context*>(ewkContext)->cookieManager();
216
}
235
}
217
236
237
Eina_Bool ewk_context_favicon_database_directory_set(Ewk_Context* ewkContext, const char* directoryPath)
238
{
239
    EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, false);
240
241
    return ewkContext->setFaviconDatabaseDirectoryPath(String::fromUTF8(directoryPath));
242
}
243
218
Ewk_Favicon_Database* ewk_context_favicon_database_get(const Ewk_Context* ewkContext)
244
Ewk_Favicon_Database* ewk_context_favicon_database_get(const Ewk_Context* ewkContext)
219
{
245
{
220
    EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, 0);
246
    EINA_SAFETY_ON_NULL_RETURN_VAL(ewkContext, 0);
- a/Source/WebKit2/UIProcess/API/efl/ewk_context.h +19 lines
Lines 184-189 EAPI Ewk_Context *ewk_context_new_with_injected_bundle_path(const char *path); a/Source/WebKit2/UIProcess/API/efl/ewk_context.h_sec1
184
EAPI Ewk_Cookie_Manager *ewk_context_cookie_manager_get(const Ewk_Context *context);
184
EAPI Ewk_Cookie_Manager *ewk_context_cookie_manager_get(const Ewk_Context *context);
185
185
186
/**
186
/**
187
 * Sets the favicon database directory for this @a context.
188
 *
189
 * Sets the directory path to be used to store the favicons database
190
 * for @a context on disk. Passing @c NULL as @a directory_path will
191
 * result in using the default directory for the platform.
192
 *
193
 * Calling this method also means enabling the favicons database for
194
 * its use from the applications, it is therefore expected to be
195
 * called only once. Further calls for the same instance of
196
 * @a context will not have any effect.
197
 *
198
 * @param context context object to update
199
 * @param directory_path database directory path to set
200
 *
201
 * @return @c EINA_TRUE if successful, @c EINA_FALSE otherwise
202
 */
203
EAPI Eina_Bool ewk_context_favicon_database_directory_set(Ewk_Context *context, const char *directory_path);
204
205
/**
187
 * Gets the favicon database instance for this @a context.
206
 * Gets the favicon database instance for this @a context.
188
 *
207
 *
189
 * @param context context object to query.
208
 * @param context context object to query.
- a/Source/WebKit2/UIProcess/API/efl/ewk_context_private.h +3 lines
Lines 55-60 public: a/Source/WebKit2/UIProcess/API/efl/ewk_context_private.h_sec1
55
55
56
    Ewk_Cookie_Manager* cookieManager();
56
    Ewk_Cookie_Manager* cookieManager();
57
57
58
    bool setFaviconDatabaseDirectoryPath(const String& databaseDirectory);
58
    Ewk_Favicon_Database* faviconDatabase();
59
    Ewk_Favicon_Database* faviconDatabase();
59
60
60
    Ewk_Storage_Manager* storageManager() const;
61
    Ewk_Storage_Manager* storageManager() const;
Lines 82-87 public: a/Source/WebKit2/UIProcess/API/efl/ewk_context_private.h_sec2
82
private:
83
private:
83
    explicit Ewk_Context(WKContextRef);
84
    explicit Ewk_Context(WKContextRef);
84
85
86
    void ensureFaviconDatabase();
87
85
    WKRetainPtr<WKContextRef> m_context;
88
    WKRetainPtr<WKContextRef> m_context;
86
89
87
    OwnPtr<Ewk_Cookie_Manager> m_cookieManager;
90
    OwnPtr<Ewk_Cookie_Manager> m_cookieManager;
- a/Source/WebKit2/UIProcess/API/efl/ewk_favicon_database.cpp -12 / +13 lines
Lines 27-32 a/Source/WebKit2/UIProcess/API/efl/ewk_favicon_database.cpp_sec1
27
#include "ewk_favicon_database.h"
27
#include "ewk_favicon_database.h"
28
28
29
#include "WKAPICast.h"
29
#include "WKAPICast.h"
30
#include "WKIconDatabase.h"
30
#include "WKURL.h"
31
#include "WKURL.h"
31
#include "WebIconDatabase.h"
32
#include "WebIconDatabase.h"
32
#include "WebURL.h"
33
#include "WebURL.h"
Lines 38-45 a/Source/WebKit2/UIProcess/API/efl/ewk_favicon_database.cpp_sec2
38
39
39
using namespace WebKit;
40
using namespace WebKit;
40
41
41
Ewk_Favicon_Database::Ewk_Favicon_Database(WKIconDatabaseRef iconDatabaseRef)
42
Ewk_Favicon_Database::Ewk_Favicon_Database(WebIconDatabase* iconDatabase)
42
    :  m_wkIconDatabase(iconDatabaseRef)
43
    :  m_iconDatabase(iconDatabase)
43
{
44
{
44
    WKIconDatabaseClient iconDatabaseClient;
45
    WKIconDatabaseClient iconDatabaseClient;
45
    memset(&iconDatabaseClient, 0, sizeof(WKIconDatabaseClient));
46
    memset(&iconDatabaseClient, 0, sizeof(WKIconDatabaseClient));
Lines 47-59 Ewk_Favicon_Database::Ewk_Favicon_Database(WKIconDatabaseRef iconDatabaseRef) a/Source/WebKit2/UIProcess/API/efl/ewk_favicon_database.cpp_sec3
47
    iconDatabaseClient.clientInfo = this;
48
    iconDatabaseClient.clientInfo = this;
48
    iconDatabaseClient.didChangeIconForPageURL = didChangeIconForPageURL;
49
    iconDatabaseClient.didChangeIconForPageURL = didChangeIconForPageURL;
49
    iconDatabaseClient.iconDataReadyForPageURL = iconDataReadyForPageURL;
50
    iconDatabaseClient.iconDataReadyForPageURL = iconDataReadyForPageURL;
50
    WKIconDatabaseSetIconDatabaseClient(m_wkIconDatabase.get(), &iconDatabaseClient);
51
    WKIconDatabaseSetIconDatabaseClient(toAPI(m_iconDatabase.get()), &iconDatabaseClient);
52
}
53
54
Ewk_Favicon_Database::~Ewk_Favicon_Database()
55
{
51
}
56
}
52
57
53
String Ewk_Favicon_Database::iconURLForPageURL(const String& pageURL) const
58
String Ewk_Favicon_Database::iconURLForPageURL(const String& pageURL) const
54
{
59
{
55
    String iconURL;
60
    String iconURL;
56
    toImpl(m_wkIconDatabase.get())->synchronousIconURLForPageURL(pageURL, iconURL);
61
    m_iconDatabase->synchronousIconURLForPageURL(pageURL, iconURL);
57
62
58
    return iconURL;
63
    return iconURL;
59
}
64
}
Lines 99-106 static Eina_Bool respond_icon_request_idle(void* data) a/Source/WebKit2/UIProcess/API/efl/ewk_favicon_database.cpp_sec4
99
104
100
void Ewk_Favicon_Database::iconForPageURL(const String& pageURL, const IconRequestCallbackData& callbackData)
105
void Ewk_Favicon_Database::iconForPageURL(const String& pageURL, const IconRequestCallbackData& callbackData)
101
{
106
{
102
    WebIconDatabase* webIconDatabase = toImpl(m_wkIconDatabase.get());
103
104
    // We ask for the icon directly. If we don't get the icon data now,
107
    // We ask for the icon directly. If we don't get the icon data now,
105
    // we'll be notified later (even if the database is still importing icons).
108
    // we'll be notified later (even if the database is still importing icons).
106
    RefPtr<cairo_surface_t> surface = getIconSurfaceSynchronously(pageURL);
109
    RefPtr<cairo_surface_t> surface = getIconSurfaceSynchronously(pageURL);
Lines 110-116 void Ewk_Favicon_Database::iconForPageURL(const String& pageURL, const IconReque a/Source/WebKit2/UIProcess/API/efl/ewk_favicon_database.cpp_sec5
110
    // finished yet, we need to wait for iconDataReadyForPageURL to be
113
    // finished yet, we need to wait for iconDataReadyForPageURL to be
111
    // called before making and informed decision.
114
    // called before making and informed decision.
112
    String iconURL = iconURLForPageURL(pageURL);
115
    String iconURL = iconURLForPageURL(pageURL);
113
    if (!surface && (!iconURL.isEmpty() || !webIconDatabase->isUrlImportCompleted())) {
116
    if (!surface && (!iconURL.isEmpty() || !m_iconDatabase->isUrlImportCompleted())) {
114
        PendingIconRequestVector requests = m_iconRequests.get(pageURL);
117
        PendingIconRequestVector requests = m_iconRequests.get(pageURL);
115
        requests.append(callbackData);
118
        requests.append(callbackData);
116
        m_iconRequests.set(pageURL, requests);
119
        m_iconRequests.set(pageURL, requests);
Lines 139-151 void Ewk_Favicon_Database::didChangeIconForPageURL(WKIconDatabaseRef, WKURLRef p a/Source/WebKit2/UIProcess/API/efl/ewk_favicon_database.cpp_sec6
139
142
140
PassRefPtr<cairo_surface_t> Ewk_Favicon_Database::getIconSurfaceSynchronously(const String& pageURL) const
143
PassRefPtr<cairo_surface_t> Ewk_Favicon_Database::getIconSurfaceSynchronously(const String& pageURL) const
141
{
144
{
142
    WebIconDatabase* webIconDatabase = toImpl(m_wkIconDatabase.get());
145
    m_iconDatabase->retainIconForPageURL(pageURL);
143
144
    webIconDatabase->retainIconForPageURL(pageURL);
145
146
146
    WebCore::NativeImagePtr icon = webIconDatabase->nativeImageForPageURL(pageURL);
147
    WebCore::NativeImagePtr icon = m_iconDatabase->nativeImageForPageURL(pageURL);
147
    if (!icon) {
148
    if (!icon) {
148
        webIconDatabase->releaseIconForPageURL(pageURL);
149
        m_iconDatabase->releaseIconForPageURL(pageURL);
149
        return 0;
150
        return 0;
150
    }
151
    }
151
152
- a/Source/WebKit2/UIProcess/API/efl/ewk_favicon_database_private.h -6 / +9 lines
Lines 26-37 a/Source/WebKit2/UIProcess/API/efl/ewk_favicon_database_private.h_sec1
26
#ifndef ewk_favicon_database_private_h
26
#ifndef ewk_favicon_database_private_h
27
#define ewk_favicon_database_private_h
27
#define ewk_favicon_database_private_h
28
28
29
#include "WKIconDatabase.h"
30
#include "WKRetainPtr.h"
31
#include "ewk_favicon_database.h"
29
#include "ewk_favicon_database.h"
32
#include <WebKit2/WKBase.h>
30
#include <WebKit2/WKBase.h>
33
#include <wtf/HashMap.h>
31
#include <wtf/HashMap.h>
34
32
33
namespace WebKit {
34
class WebIconDatabase;
35
}
36
35
struct IconChangeCallbackData {
37
struct IconChangeCallbackData {
36
    Ewk_Favicon_Database_Icon_Change_Cb callback;
38
    Ewk_Favicon_Database_Icon_Change_Cb callback;
37
    void* userData;
39
    void* userData;
Lines 71-80 typedef HashMap<String /* pageURL */, PendingIconRequestVector> PendingIconReque a/Source/WebKit2/UIProcess/API/efl/ewk_favicon_database_private.h_sec2
71
73
72
class Ewk_Favicon_Database {
74
class Ewk_Favicon_Database {
73
public:
75
public:
74
    static PassOwnPtr<Ewk_Favicon_Database> create(WKIconDatabaseRef iconDatabaseRef)
76
    static PassOwnPtr<Ewk_Favicon_Database> create(WebKit::WebIconDatabase* iconDatabase)
75
    {
77
    {
76
        return adoptPtr(new Ewk_Favicon_Database(iconDatabaseRef));
78
        return adoptPtr(new Ewk_Favicon_Database(iconDatabase));
77
    }
79
    }
80
    ~Ewk_Favicon_Database();
78
81
79
    String iconURLForPageURL(const String& pageURL) const;
82
    String iconURLForPageURL(const String& pageURL) const;
80
    void iconForPageURL(const String& pageURL, const IconRequestCallbackData& callbackData);
83
    void iconForPageURL(const String& pageURL, const IconRequestCallbackData& callbackData);
Lines 83-96 public: a/Source/WebKit2/UIProcess/API/efl/ewk_favicon_database_private.h_sec3
83
    void unwatchChanges(Ewk_Favicon_Database_Icon_Change_Cb callback);
86
    void unwatchChanges(Ewk_Favicon_Database_Icon_Change_Cb callback);
84
87
85
private:
88
private:
86
    explicit Ewk_Favicon_Database(WKIconDatabaseRef iconDatabaseRef);
89
    explicit Ewk_Favicon_Database(WebKit::WebIconDatabase* iconDatabase);
87
90
88
    PassRefPtr<cairo_surface_t> getIconSurfaceSynchronously(const String& pageURL) const;
91
    PassRefPtr<cairo_surface_t> getIconSurfaceSynchronously(const String& pageURL) const;
89
92
90
    static void didChangeIconForPageURL(WKIconDatabaseRef iconDatabase, WKURLRef pageURL, const void* clientInfo);
93
    static void didChangeIconForPageURL(WKIconDatabaseRef iconDatabase, WKURLRef pageURL, const void* clientInfo);
91
    static void iconDataReadyForPageURL(WKIconDatabaseRef iconDatabase, WKURLRef pageURL, const void* clientInfo);
94
    static void iconDataReadyForPageURL(WKIconDatabaseRef iconDatabase, WKURLRef pageURL, const void* clientInfo);
92
95
93
    WKRetainPtr<WKIconDatabaseRef> m_wkIconDatabase;
96
    RefPtr<WebKit::WebIconDatabase> m_iconDatabase;
94
    ChangeListenerMap m_changeListeners;
97
    ChangeListenerMap m_changeListeners;
95
    PendingIconRequestMap m_iconRequests;
98
    PendingIconRequestMap m_iconRequests;
96
};
99
};
- a/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_favicon_database.cpp -1 / +8 lines
Lines 89-94 TEST_F(EWK2UnitTestBase, ewk_favicon_database_url_get) a/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_favicon_database.cpp_sec1
89
    OwnPtr<EWK2UnitTestServer> httpServer = adoptPtr(new EWK2UnitTestServer);
89
    OwnPtr<EWK2UnitTestServer> httpServer = adoptPtr(new EWK2UnitTestServer);
90
    httpServer->run(serverCallback);
90
    httpServer->run(serverCallback);
91
91
92
    // Set favicon database path and enable functionality.
93
    Ewk_Context* context = ewk_view_context_get(webView());
94
    ewk_context_favicon_database_directory_set(context, 0);
95
92
    bool iconChanged = false;
96
    bool iconChanged = false;
93
    evas_object_smart_callback_add(webView(), "icon,changed", onIconChanged, &iconChanged);
97
    evas_object_smart_callback_add(webView(), "icon,changed", onIconChanged, &iconChanged);
94
98
Lines 103-109 TEST_F(EWK2UnitTestBase, ewk_favicon_database_url_get) a/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_favicon_database.cpp_sec2
103
    evas_object_smart_callback_del(webView(), "icon,changed", onIconChanged);
107
    evas_object_smart_callback_del(webView(), "icon,changed", onIconChanged);
104
108
105
    // Check the API retrieving a favicon URL.
109
    // Check the API retrieving a favicon URL.
106
    Ewk_Context* context = ewk_view_context_get(webView());
107
    Ewk_Favicon_Database* faviconDatabase = ewk_context_favicon_database_get(context);
110
    Ewk_Favicon_Database* faviconDatabase = ewk_context_favicon_database_get(context);
108
    ASSERT_TRUE(faviconDatabase);
111
    ASSERT_TRUE(faviconDatabase);
109
112
Lines 146-151 TEST_F(EWK2UnitTestBase, ewk_favicon_database_async_icon_get) a/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_favicon_database.cpp_sec3
146
    OwnPtr<EWK2UnitTestServer> httpServer = adoptPtr(new EWK2UnitTestServer);
149
    OwnPtr<EWK2UnitTestServer> httpServer = adoptPtr(new EWK2UnitTestServer);
147
    httpServer->run(serverCallback);
150
    httpServer->run(serverCallback);
148
151
152
    // Set favicon database path and enable functionality.
153
    Ewk_Context* context = ewk_view_context_get(webView());
154
    ewk_context_favicon_database_directory_set(context, 0);
155
149
    IconRequestData data = { webView(), 0 };
156
    IconRequestData data = { webView(), 0 };
150
    evas_object_smart_callback_add(webView(), "icon,changed", requestFaviconData, &data);
157
    evas_object_smart_callback_add(webView(), "icon,changed", requestFaviconData, &data);
151
158
- a/Tools/ChangeLog +14 lines
Lines 1-3 a/Tools/ChangeLog_sec1
1
2012-11-04  Christophe Dumez  <christophe.dumez@intel.com>
2
3
        101182_iconDatabase_path
4
5
        [EFL][WK2] The icon database path should be set by the client
6
        https://bugs.webkit.org/show_bug.cgi?id=101182
7
8
        Reviewed by NOBODY (OOPS!).
9
10
        Additional information of the change such as approach, rationale. Please add per-function descriptions below (OOPS!).
11
12
        * MiniBrowser/efl/main.c:
13
        (elm_main):
14
1
2012-11-03  Balazs Kelemen  <kbalazs@webkit.org>
15
2012-11-03  Balazs Kelemen  <kbalazs@webkit.org>
2
16
3
        [Qt][WK2] setPlatformStrategies always asserts after r132744
17
        [Qt][WK2] setPlatformStrategies always asserts after r132744
- a/Tools/MiniBrowser/efl/main.c +4 lines
Lines 995-1000 elm_main(int argc, char *argv[]) a/Tools/MiniBrowser/efl/main.c_sec1
995
    }
995
    }
996
#endif
996
#endif
997
997
998
    // Enable favicon database.
999
    Ewk_Context *context = ewk_context_default_get();
1000
    ewk_context_favicon_database_directory_set(context, NULL);
1001
998
    if (args < argc) {
1002
    if (args < argc) {
999
        char *url = url_from_user_input(argv[args]);
1003
        char *url = url_from_user_input(argv[args]);
1000
        window = window_create(url);
1004
        window = window_create(url);

Return to Bug 101182