[EFL][WK2] Add ewk API to allow accepting a specific TLS certificate for a specific...
[WebKit-https.git] / Source / WebKit2 / UIProcess / API / efl / ewk_context_private.h
1 /*
2  * Copyright (C) 2012 Samsung Electronics
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Library General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public License
15  * along with this library; see the file COPYING.LIB.  If not, write to
16  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17  * Boston, MA 02110-1301, USA.
18  */
19
20 #ifndef ewk_context_private_h
21 #define ewk_context_private_h
22
23 #include "ewk_context.h"
24 #include "ewk_object_private.h"
25 #include <JavaScriptCore/JSContextRef.h>
26 #include <WebKit/WKBase.h>
27 #include <WebKit/WKRetainPtr.h>
28 #include <wtf/RefPtr.h>
29 #include <wtf/text/WTFString.h>
30
31 using namespace WebKit;
32
33 class EwkApplicationCacheManager;
34 class EwkCookieManager;
35 class EwkFaviconDatabase;
36
37 namespace WebKit {
38 class ContextHistoryClientEfl;
39 class DownloadManagerEfl;
40 class RequestManagerClientEfl;
41 #if ENABLE(BATTERY_STATUS)
42 class BatteryProvider;
43 #endif
44 }
45
46 class EwkContext : public EwkObject {
47 public:
48     EWK_OBJECT_DECLARE(EwkContext)
49
50     static PassRefPtr<EwkContext> findOrCreateWrapper(WKContextRef context);
51     static PassRefPtr<EwkContext> create();
52     static PassRefPtr<EwkContext> create(const String& injectedBundlePath);
53
54     static EwkContext* defaultContext();
55
56     ~EwkContext();
57
58     EwkApplicationCacheManager* applicationCacheManager();
59     EwkCookieManager* cookieManager();
60     EwkDatabaseManager* databaseManager();
61
62     bool setFaviconDatabaseDirectoryPath(const String& databaseDirectory);
63     EwkFaviconDatabase* faviconDatabase();
64
65     EwkStorageManager* storageManager() const;
66
67     WebKit::RequestManagerClientEfl* requestManager();
68
69     void addVisitedLink(const String& visitedURL);
70
71     void setCacheModel(Ewk_Cache_Model);
72
73     Ewk_Cache_Model cacheModel() const;
74
75     void setProcessModel(Ewk_Process_Model);
76
77     Ewk_Process_Model processModel() const;
78
79     WKContextRef wkContext() const { return m_context.get(); }
80
81     WebKit::DownloadManagerEfl* downloadManager() const;
82
83     WebKit::ContextHistoryClientEfl* historyClient();
84
85     Ewk_TLS_Error_Policy ignoreTLSErrors() const;
86
87     void setIgnoreTLSErrors(Ewk_TLS_Error_Policy TLSErrorPolicy) const;
88
89     const String& extensionsPath() const { return m_extensionsPath; }
90
91     void allowSpecificHTTPSCertificateForHost(const String& pem, const String& host) const;
92
93 #if ENABLE(NETSCAPE_PLUGIN_API)
94     void setAdditionalPluginPath(const String&);
95 #endif
96
97     void clearResourceCache();
98
99     JSGlobalContextRef jsGlobalContext();
100
101     static void didReceiveMessageFromInjectedBundle(WKContextRef, WKStringRef messageName, WKTypeRef messageBody, const void* clientInfo);
102     static void didReceiveSynchronousMessageFromInjectedBundle(WKContextRef, WKStringRef messageName, WKTypeRef messageBody, WKTypeRef* returnData, const void* clientInfo);
103     static WKTypeRef getInjectedBundleInitializationUserData(WKContextRef, const void* clientInfo);
104     void setMessageFromInjectedBundleCallback(Ewk_Context_Message_From_Injected_Bundle_Cb, void*);
105     void processReceivedMessageFromInjectedBundle(WKStringRef messageName, WKTypeRef messageBody, WKTypeRef* returnData);
106
107 private:
108     explicit EwkContext(WKContextRef, const String& extensionsPath = String());
109
110     void ensureFaviconDatabase();
111
112     WKRetainPtr<WKContextRef> m_context;
113
114     std::unique_ptr<EwkApplicationCacheManager> m_applicationCacheManager;
115     std::unique_ptr<EwkCookieManager> m_cookieManager;
116     std::unique_ptr<EwkDatabaseManager> m_databaseManager;
117     std::unique_ptr<EwkFaviconDatabase> m_faviconDatabase;
118     std::unique_ptr<EwkStorageManager> m_storageManager;
119 #if ENABLE(BATTERY_STATUS)
120     RefPtr<WebKit::BatteryProvider> m_batteryProvider;
121 #endif
122     std::unique_ptr<WebKit::DownloadManagerEfl> m_downloadManager;
123     std::unique_ptr<WebKit::RequestManagerClientEfl> m_requestManagerClient;
124
125     std::unique_ptr<WebKit::ContextHistoryClientEfl> m_historyClient;
126
127     JSGlobalContextRef m_jsGlobalContext;
128
129     String m_extensionsPath;
130
131     struct {
132         Ewk_Context_Message_From_Injected_Bundle_Cb callback;
133         void* userData;
134     } m_callbackForMessageFromInjectedBundle;
135 };
136
137 #endif // ewk_context_private_h