WebKit2/UIProcess/API/C/WKContext.cpp
changeset 0 4f2f89ce4247
equal deleted inserted replaced
-1:000000000000 0:4f2f89ce4247
       
     1 /*
       
     2  * Copyright (C) 2010 Apple Inc. All rights reserved.
       
     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 "WKContext.h"
       
    27 #include "WKContextPrivate.h"
       
    28 
       
    29 #include "WKAPICast.h"
       
    30 #include "WebContext.h"
       
    31 #include "WebPreferences.h"
       
    32 #include <WebCore/PlatformString.h>
       
    33 #include <wtf/PassRefPtr.h>
       
    34 #include <wtf/RefPtr.h>
       
    35 
       
    36 using namespace WebKit;
       
    37 
       
    38 WKContextRef WKContextCreate()
       
    39 {
       
    40     RefPtr<WebContext> context = WebContext::create(WebCore::String());
       
    41     return toRef(context.release().releaseRef());
       
    42 }
       
    43 
       
    44 WKContextRef WKContextCreateWithInjectedBundlePath(WKStringRef pathRef)
       
    45 {
       
    46     RefPtr<WebContext> context = WebContext::create(toWK(pathRef));
       
    47     return toRef(context.release().releaseRef());
       
    48 }
       
    49 
       
    50 WKContextRef WKContextGetSharedProcessContext()
       
    51 {
       
    52     return toRef(WebContext::sharedProcessContext());
       
    53 }
       
    54 
       
    55 WKContextRef WKContextGetSharedThreadContext()
       
    56 {
       
    57     return toRef(WebContext::sharedThreadContext());
       
    58 }
       
    59 
       
    60 void WKContextSetPreferences(WKContextRef contextRef, WKPreferencesRef preferencesRef)
       
    61 {
       
    62     toWK(contextRef)->setPreferences(toWK(preferencesRef));
       
    63 }
       
    64 
       
    65 WKPreferencesRef WKContextGetPreferences(WKContextRef contextRef)
       
    66 {
       
    67     return toRef(toWK(contextRef)->preferences());
       
    68 }
       
    69 
       
    70 void WKContextSetInjectedBundleClient(WKContextRef contextRef, WKContextInjectedBundleClient* wkClient)
       
    71 {
       
    72     if (wkClient && !wkClient->version)
       
    73         toWK(contextRef)->initializeInjectedBundleClient(wkClient);
       
    74 }
       
    75 
       
    76 void WKContextPostMessageToInjectedBundle(WKContextRef contextRef, WKStringRef messageRef)
       
    77 {
       
    78     toWK(contextRef)->postMessageToInjectedBundle(toWK(messageRef));
       
    79 }
       
    80 
       
    81 void WKContextGetStatistics(WKContextRef contextRef, WKContextStatistics* statistics)
       
    82 {
       
    83     toWK(contextRef)->getStatistics(statistics);
       
    84 }
       
    85 
       
    86 WKContextRef WKContextRetain(WKContextRef contextRef)
       
    87 {
       
    88     toWK(contextRef)->ref();
       
    89     return contextRef;
       
    90 }
       
    91 
       
    92 void WKContextRelease(WKContextRef contextRef)
       
    93 {
       
    94     toWK(contextRef)->deref();
       
    95 }
       
    96 
       
    97 void _WKContextSetAdditionalPluginPath(WKContextRef contextRef, WKStringRef pluginPath)
       
    98 {
       
    99     toWK(contextRef)->setAdditionalPluginPath(toWK(pluginPath));
       
   100 }