Changeset 130621 in webkit
- Timestamp:
- Oct 8, 2012, 1:05:26 AM (14 years ago)
- Location:
- trunk/Source/WebKit2
- Files:
-
- 7 edited
-
ChangeLog (modified) (1 diff)
-
UIProcess/API/gtk/WebKitDownloadClient.cpp (modified) (8 diffs)
-
UIProcess/API/gtk/WebKitRequestManagerClient.cpp (modified) (1 diff)
-
UIProcess/API/gtk/WebKitSecurityManager.cpp (modified) (1 diff)
-
UIProcess/API/gtk/WebKitWebContext.cpp (modified) (19 diffs)
-
UIProcess/API/gtk/WebKitWebContextPrivate.h (modified) (1 diff)
-
UIProcess/API/gtk/WebKitWebView.cpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit2/ChangeLog
r130614 r130621 1 2012-10-08 Carlos Garcia Campos <cgarcia@igalia.com> 2 3 [GTK] Don't use the C API internally in WebKitWebContext 4 https://bugs.webkit.org/show_bug.cgi?id=96768 5 6 Reviewed by Martin Robinson. 7 8 Using the C++ classes directly instead of the C API wrappers we 9 avoid a lot of toImpl/toAPI casts, string conversions and 10 allocations. The code is also a lot simpler and easier to read. 11 12 * UIProcess/API/gtk/WebKitDownloadClient.cpp: 13 (didStart): 14 (didReceiveResponse): 15 (didReceiveData): 16 (decideDestinationWithSuggestedFilename): 17 (didCreateDestination): 18 (didFail): 19 (didCancel): 20 (didFinish): 21 (attachDownloadClientToContext): 22 * UIProcess/API/gtk/WebKitRequestManagerClient.cpp: 23 (attachRequestManagerClientToContext): 24 * UIProcess/API/gtk/WebKitSecurityManager.cpp: 25 (registerSecurityPolicyForURIScheme): 26 * UIProcess/API/gtk/WebKitWebContext.cpp: 27 (_WebKitWebContextPrivate): 28 (createDefaultWebContext): 29 (webkit_web_context_set_cache_model): 30 (webkit_web_context_get_cache_model): 31 (webkit_web_context_clear_cache): 32 (webkit_web_context_download_uri): 33 (webkit_web_context_get_cookie_manager): 34 (webkit_web_context_get_favicon_database_directory): 35 (webkit_web_context_get_favicon_database): 36 (webkit_web_context_set_additional_plugins_directory): 37 (webkitWebContextGetPluginThread): 38 (webkit_web_context_register_uri_scheme): 39 (webkitWebContextGetOrCreateDownload): 40 (webkitWebContextRemoveDownload): 41 (webkitWebContextGetContext): 42 (webkitWebContextGetRequestManager): 43 * UIProcess/API/gtk/WebKitWebContextPrivate.h: 44 * UIProcess/API/gtk/WebKitWebView.cpp: 45 (webkitWebViewConstructed): 46 1 47 2012-10-07 Kangil Han <kangil.han@samsung.com> 2 48 -
trunk/Source/WebKit2/UIProcess/API/gtk/WebKitDownloadClient.cpp
r105708 r130621 35 35 static void didStart(WKContextRef, WKDownloadRef wkDownload, const void* clientInfo) 36 36 { 37 GRefPtr<WebKitDownload> download = webkitWebContextGetOrCreateDownload( wkDownload);37 GRefPtr<WebKitDownload> download = webkitWebContextGetOrCreateDownload(toImpl(wkDownload)); 38 38 webkitWebContextDownloadStarted(WEBKIT_WEB_CONTEXT(clientInfo), download.get()); 39 39 } … … 41 41 static void didReceiveResponse(WKContextRef, WKDownloadRef wkDownload, WKURLResponseRef wkResponse, const void* clientInfo) 42 42 { 43 GRefPtr<WebKitDownload> download = webkitWebContextGetOrCreateDownload( wkDownload);43 GRefPtr<WebKitDownload> download = webkitWebContextGetOrCreateDownload(toImpl(wkDownload)); 44 44 if (webkitDownloadIsCancelled(download.get())) 45 45 return; … … 51 51 static void didReceiveData(WKContextRef, WKDownloadRef wkDownload, uint64_t length, const void* clientInfo) 52 52 { 53 GRefPtr<WebKitDownload> download = webkitWebContextGetOrCreateDownload( wkDownload);53 GRefPtr<WebKitDownload> download = webkitWebContextGetOrCreateDownload(toImpl(wkDownload)); 54 54 webkitDownloadNotifyProgress(download.get(), length); 55 55 } … … 57 57 static WKStringRef decideDestinationWithSuggestedFilename(WKContextRef, WKDownloadRef wkDownload, WKStringRef filename, bool* allowOverwrite, const void* clientInfo) 58 58 { 59 GRefPtr<WebKitDownload> download = webkitWebContextGetOrCreateDownload( wkDownload);59 GRefPtr<WebKitDownload> download = webkitWebContextGetOrCreateDownload(toImpl(wkDownload)); 60 60 CString destinationURI = webkitDownloadDecideDestinationWithSuggestedFilename(download.get(), 61 61 toImpl(filename)->string().utf8()); … … 65 65 static void didCreateDestination(WKContextRef, WKDownloadRef wkDownload, WKStringRef path, const void* clientInfo) 66 66 { 67 GRefPtr<WebKitDownload> download = webkitWebContextGetOrCreateDownload( wkDownload);67 GRefPtr<WebKitDownload> download = webkitWebContextGetOrCreateDownload(toImpl(wkDownload)); 68 68 webkitDownloadDestinationCreated(download.get(), toImpl(path)->string().utf8()); 69 69 } … … 71 71 static void didFail(WKContextRef, WKDownloadRef wkDownload, WKErrorRef error, const void *clientInfo) 72 72 { 73 GRefPtr<WebKitDownload> download = webkitWebContextGetOrCreateDownload( wkDownload);73 GRefPtr<WebKitDownload> download = webkitWebContextGetOrCreateDownload(toImpl(wkDownload)); 74 74 if (webkitDownloadIsCancelled(download.get())) { 75 75 // Cancellation takes precedence over other errors. … … 77 77 } else 78 78 webkitDownloadFailed(download.get(), toImpl(error)->platformError()); 79 webkitWebContextRemoveDownload( wkDownload);79 webkitWebContextRemoveDownload(toImpl(wkDownload)); 80 80 } 81 81 82 82 static void didCancel(WKContextRef, WKDownloadRef wkDownload, const void *clientInfo) 83 83 { 84 GRefPtr<WebKitDownload> download = webkitWebContextGetOrCreateDownload( wkDownload);84 GRefPtr<WebKitDownload> download = webkitWebContextGetOrCreateDownload(toImpl(wkDownload)); 85 85 webkitDownloadCancelled(download.get()); 86 webkitWebContextRemoveDownload( wkDownload);86 webkitWebContextRemoveDownload(toImpl(wkDownload)); 87 87 } 88 88 89 89 static void didFinish(WKContextRef wkContext, WKDownloadRef wkDownload, const void *clientInfo) 90 90 { 91 GRefPtr<WebKitDownload> download = webkitWebContextGetOrCreateDownload( wkDownload);91 GRefPtr<WebKitDownload> download = webkitWebContextGetOrCreateDownload(toImpl(wkDownload)); 92 92 webkitDownloadFinished(download.get()); 93 webkitWebContextRemoveDownload( wkDownload);93 webkitWebContextRemoveDownload(toImpl(wkDownload)); 94 94 } 95 95 … … 111 111 0, // processDidCrash 112 112 }; 113 WKContextSetDownloadClient( webkitWebContextGetWKContext(webContext), &wkDownloadClient);113 WKContextSetDownloadClient(toAPI(webkitWebContextGetContext(webContext)), &wkDownloadClient); 114 114 } 115 115 -
trunk/Source/WebKit2/UIProcess/API/gtk/WebKitRequestManagerClient.cpp
r130259 r130621 47 47 didFailToLoadURIRequest 48 48 }; 49 WKSoupRequestManagerSetClient( webkitWebContextGetRequestManager(webContext), &wkRequestManagerClient);49 WKSoupRequestManagerSetClient(toAPI(webkitWebContextGetRequestManager(webContext)), &wkRequestManagerClient); 50 50 } 51 51 -
trunk/Source/WebKit2/UIProcess/API/gtk/WebKitSecurityManager.cpp
r128989 r130621 75 75 { 76 76 String urlScheme = String::fromUTF8(scheme); 77 WebContext* webContext = toImpl(webkitWebContextGetWKContext(manager->priv->webContext));77 WebContext* webContext = webkitWebContextGetContext(manager->priv->webContext); 78 78 79 79 // We keep the WebCore::SchemeRegistry of the UI process in sync with the -
trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.cpp
r129906 r130621 21 21 #include "WebKitWebContext.h" 22 22 23 #include "WebContext.h"24 23 #include "WebKitCookieManagerPrivate.h" 25 24 #include "WebKitDownloadClient.h" … … 34 33 #include "WebKitURISchemeRequestPrivate.h" 35 34 #include "WebKitWebContextPrivate.h" 35 #include "WebResourceCacheManagerProxy.h" 36 36 #include <WebCore/FileSystem.h> 37 37 #include <WebCore/IconDatabase.h> … … 44 44 #include <wtf/gobject/GRefPtr.h> 45 45 #include <wtf/text/CString.h> 46 47 using namespace WebKit;48 46 49 47 enum { … … 96 94 97 95 struct _WebKitWebContextPrivate { 98 WKRetainPtr<WKContextRef> context;96 RefPtr<WebContext> context; 99 97 100 98 GRefPtr<WebKitCookieManager> cookieManager; 101 99 GRefPtr<WebKitFaviconDatabase> faviconDatabase; 102 100 GRefPtr<WebKitSecurityManager> securityManager; 103 WKRetainPtr<WKSoupRequestManagerRef> requestManager;101 RefPtr<WebSoupRequestManagerProxy> requestManager; 104 102 URISchemeHandlerMap uriSchemeHandlers; 105 103 URISchemeRequestMap uriSchemeRequests; … … 157 155 { 158 156 static GRefPtr<WebKitWebContext> webContext = adoptGRef(WEBKIT_WEB_CONTEXT(g_object_new(WEBKIT_TYPE_WEB_CONTEXT, NULL))); 159 webContext->priv->context = WKContextCreate(); 160 webContext->priv->requestManager = WKContextGetSoupRequestManager(webContext->priv->context.get()); 161 WKContextSetCacheModel(webContext->priv->context.get(), kWKCacheModelPrimaryWebBrowser); 157 WebKitWebContextPrivate* priv = webContext->priv; 158 159 priv->context = WebContext::create(String()); 160 priv->requestManager = webContext->priv->context->soupRequestManagerProxy(); 161 priv->context->setCacheModel(CacheModelPrimaryWebBrowser); 162 162 163 attachDownloadClientToContext(webContext.get()); 163 164 attachRequestManagerClientToContext(webContext.get()); 165 164 166 #if ENABLE(GEOLOCATION) 165 WKGeolocationManagerRef wkGeolocationManager = WKContextGetGeolocationManager(webContext->priv->context.get()); 166 webContext->priv->geolocationProvider = WebKitGeolocationProvider::create(wkGeolocationManager); 167 priv->geolocationProvider = WebKitGeolocationProvider::create(toAPI(priv->context->geolocationManagerProxy())); 167 168 #endif 168 169 #if ENABLE(SPELLCHECK) 169 webContext->priv->textChecker = WebKitTextChecker::create();170 priv->textChecker = WebKitTextChecker::create(); 170 171 #endif 171 172 return webContext.get(); … … 211 212 void webkit_web_context_set_cache_model(WebKitWebContext* context, WebKitCacheModel model) 212 213 { 213 WKCacheModel cacheModel;214 CacheModel cacheModel; 214 215 215 216 g_return_if_fail(WEBKIT_IS_WEB_CONTEXT(context)); … … 217 218 switch (model) { 218 219 case WEBKIT_CACHE_MODEL_DOCUMENT_VIEWER: 219 cacheModel = kWKCacheModelDocumentViewer;220 cacheModel = CacheModelDocumentViewer; 220 221 break; 221 222 case WEBKIT_CACHE_MODEL_WEB_BROWSER: 222 cacheModel = kWKCacheModelPrimaryWebBrowser;223 cacheModel = CacheModelPrimaryWebBrowser; 223 224 break; 224 225 case WEBKIT_CACHE_MODEL_DOCUMENT_BROWSER: 225 cacheModel = kWKCacheModelDocumentBrowser;226 cacheModel = CacheModelDocumentBrowser; 226 227 break; 227 228 default: 228 229 g_assert_not_reached(); 229 230 } 230 WebKitWebContextPrivate* priv = context->priv; 231 if (cacheModel != WKContextGetCacheModel(priv->context.get()))232 WKContextSetCacheModel(priv->context.get(),cacheModel);231 232 if (cacheModel != context->priv->context->cacheModel()) 233 context->priv->context->setCacheModel(cacheModel); 233 234 } 234 235 … … 247 248 g_return_val_if_fail(WEBKIT_IS_WEB_CONTEXT(context), WEBKIT_CACHE_MODEL_WEB_BROWSER); 248 249 249 WebKitWebContextPrivate* priv = context->priv; 250 switch (WKContextGetCacheModel(priv->context.get())) { 251 case kWKCacheModelDocumentViewer: 250 switch (context->priv->context->cacheModel()) { 251 case CacheModelDocumentViewer: 252 252 return WEBKIT_CACHE_MODEL_DOCUMENT_VIEWER; 253 case kWKCacheModelPrimaryWebBrowser:253 case CacheModelPrimaryWebBrowser: 254 254 return WEBKIT_CACHE_MODEL_WEB_BROWSER; 255 case kWKCacheModelDocumentBrowser:255 case CacheModelDocumentBrowser: 256 256 return WEBKIT_CACHE_MODEL_DOCUMENT_BROWSER; 257 257 default: … … 273 273 g_return_if_fail(WEBKIT_IS_WEB_CONTEXT(context)); 274 274 275 WebKitWebContextPrivate* priv = context->priv; 276 WKResourceCacheManagerClearCacheForAllOrigins(WKContextGetResourceCacheManager(priv->context.get()), WKResourceCachesToClearAll); 277 } 278 279 typedef HashMap<WKDownloadRef, GRefPtr<WebKitDownload> > DownloadsMap; 275 context->priv->context->resourceCacheManagerProxy()->clearCacheForAllOrigins(AllResourceCaches); 276 } 277 278 typedef HashMap<DownloadProxy*, GRefPtr<WebKitDownload> > DownloadsMap; 280 279 281 280 static DownloadsMap& downloadsMap() … … 300 299 g_return_val_if_fail(uri, 0); 301 300 302 WebKitWebContextPrivate* priv = context->priv; 303 WKRetainPtr<WKURLRef> wkURL(AdoptWK, WKURLCreateWithUTF8CString(uri)); 304 WKRetainPtr<WKURLRequestRef> wkRequest(AdoptWK, WKURLRequestCreateWithWKURL(wkURL.get())); 305 WKRetainPtr<WKDownloadRef> wkDownload = WKContextDownloadURLRequest(priv->context.get(), wkRequest.get()); 306 WebKitDownload* download = webkitDownloadCreate(wkDownload.get()); 307 downloadsMap().set(wkDownload.get(), download); 301 DownloadProxy* downloadProxy = context->priv->context->download(0, WebCore::ResourceRequest(String::fromUTF8(uri))); 302 WebKitDownload* download = webkitDownloadCreate(toAPI(downloadProxy)); 303 downloadsMap().set(downloadProxy, download); 308 304 return download; 309 305 } … … 323 319 WebKitWebContextPrivate* priv = context->priv; 324 320 if (!priv->cookieManager) 325 priv->cookieManager = adoptGRef(webkitCookieManagerCreate( WKContextGetCookieManager(priv->context.get())));321 priv->cookieManager = adoptGRef(webkitCookieManagerCreate(toAPI(priv->context->cookieManagerProxy()))); 326 322 327 323 return priv->cookieManager.get(); … … 378 374 // Use default if a different path has not been previously set. 379 375 if (priv->faviconDatabasePath.isNull()) 380 priv->faviconDatabasePath = toImpl(priv->context.get())->iconDatabasePath().utf8();376 priv->faviconDatabasePath = priv->context->iconDatabasePath().utf8(); 381 377 382 378 return priv->faviconDatabasePath.data(); … … 409 405 410 406 // Calling the setter in WebContext will cause the icon database to be opened. 411 WebContext* webContext = toImpl(priv->context.get()); 412 webContext->setIconDatabasePath(WebCore::filenameToString(faviconDatabasePath.get())); 413 priv->faviconDatabase = adoptGRef(webkitFaviconDatabaseCreate(webContext->iconDatabase())); 407 priv->context->setIconDatabasePath(WebCore::filenameToString(faviconDatabasePath.get())); 408 priv->faviconDatabase = adoptGRef(webkitFaviconDatabaseCreate(priv->context->iconDatabase())); 414 409 415 410 return priv->faviconDatabase.get(); … … 447 442 g_return_if_fail(directory); 448 443 449 toImpl(context->priv->context.get())->setAdditionalPluginsDirectory(WebCore::filenameToString(directory));444 context->priv->context->setAdditionalPluginsDirectory(WebCore::filenameToString(directory)); 450 445 } 451 446 … … 458 453 { 459 454 GetPluginsAsyncData* data = static_cast<GetPluginsAsyncData*>(g_simple_async_result_get_op_res_gpointer(result)); 460 data->plugins = toImpl(WEBKIT_WEB_CONTEXT(object)->priv->context.get())->pluginInfoStore().plugins();455 data->plugins = WEBKIT_WEB_CONTEXT(object)->priv->context->pluginInfoStore().plugins(); 461 456 } 462 457 … … 565 560 RefPtr<WebKitURISchemeHandler> handler = adoptRef(new WebKitURISchemeHandler(callback, userData, destroyNotify)); 566 561 context->priv->uriSchemeHandlers.set(String::fromUTF8(scheme), handler.get()); 567 WKRetainPtr<WKStringRef> wkScheme(AdoptWK, WKStringCreateWithUTF8CString(scheme)); 568 WKSoupRequestManagerRegisterURIScheme(context->priv->requestManager.get(), wkScheme.get()); 562 context->priv->requestManager->registerURIScheme(String::fromUTF8(scheme)); 569 563 } 570 564 … … 680 674 } 681 675 682 WebKitDownload* webkitWebContextGetOrCreateDownload( WKDownloadRef wkDownload)683 { 684 GRefPtr<WebKitDownload> download = downloadsMap().get( wkDownload);676 WebKitDownload* webkitWebContextGetOrCreateDownload(DownloadProxy* downloadProxy) 677 { 678 GRefPtr<WebKitDownload> download = downloadsMap().get(downloadProxy); 685 679 if (download) 686 680 return download.get(); 687 681 688 download = adoptGRef(webkitDownloadCreate( wkDownload));689 downloadsMap().set( wkDownload, download.get());682 download = adoptGRef(webkitDownloadCreate(toAPI(downloadProxy))); 683 downloadsMap().set(downloadProxy, download.get()); 690 684 return download.get(); 691 685 } 692 686 693 void webkitWebContextRemoveDownload( WKDownloadRef wkDownload)694 { 695 downloadsMap().remove( wkDownload);687 void webkitWebContextRemoveDownload(DownloadProxy* downloadProxy) 688 { 689 downloadsMap().remove(downloadProxy); 696 690 } 697 691 … … 701 695 } 702 696 703 W KContextRef webkitWebContextGetWKContext(WebKitWebContext* context)697 WebContext* webkitWebContextGetContext(WebKitWebContext* context) 704 698 { 705 699 g_assert(WEBKIT_IS_WEB_CONTEXT(context)); … … 708 702 } 709 703 710 W KSoupRequestManagerRefwebkitWebContextGetRequestManager(WebKitWebContext* context)704 WebSoupRequestManagerProxy* webkitWebContextGetRequestManager(WebKitWebContext* context) 711 705 { 712 706 return context->priv->requestManager.get(); -
trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebContextPrivate.h
r119700 r130621 27 27 #define WebKitWebContextPrivate_h 28 28 29 #include "DownloadProxy.h" 30 #include "WebContext.h" 29 31 #include "WebKitPrivate.h" 30 32 #include "WebKitURISchemeRequest.h" 31 33 #include "WebKitWebContext.h" 34 #include "WebSoupRequestManagerProxy.h" 32 35 33 WKContextRef webkitWebContextGetWKContext(WebKitWebContext*); 34 WebKitDownload* webkitWebContextGetOrCreateDownload(WKDownloadRef); 35 void webkitWebContextRemoveDownload(WKDownloadRef); 36 using namespace WebKit; 37 38 WebContext* webkitWebContextGetContext(WebKitWebContext*); 39 WebKitDownload* webkitWebContextGetOrCreateDownload(DownloadProxy*); 40 void webkitWebContextRemoveDownload(DownloadProxy*); 36 41 void webkitWebContextDownloadStarted(WebKitWebContext*, WebKitDownload*); 37 W KSoupRequestManagerRefwebkitWebContextGetRequestManager(WebKitWebContext*);42 WebSoupRequestManagerProxy* webkitWebContextGetRequestManager(WebKitWebContext*); 38 43 void webkitWebContextReceivedURIRequest(WebKitWebContext*, WebKitURISchemeRequest*); 39 44 void webkitWebContextDidFailToLoadURIRequest(WebKitWebContext*, uint64_t requestID); -
trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp
r130612 r130621 399 399 WebKitWebViewBase* webViewBase = WEBKIT_WEB_VIEW_BASE(webView); 400 400 401 webkitWebViewBaseCreateWebPage(webViewBase, toImpl(webkitWebContextGetWKContext(priv->context)), 0);401 webkitWebViewBaseCreateWebPage(webViewBase, webkitWebContextGetContext(priv->context), 0); 402 402 403 403 attachLoaderClientToView(webView);
Note:
See TracChangeset
for help on using the changeset viewer.