13fb09f92a39a967c3bcdd88bdffe6ca8c03256d
[WebKit-https.git] / WebKit2 / WebProcess / InjectedBundle / API / c / WKBundlePage.cpp
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 "WKBundlePage.h"
27 #include "WKBundlePagePrivate.h"
28
29 #include "InjectedBundleBackForwardList.h"
30 #include "WKAPICast.h"
31 #include "WKBundleAPICast.h"
32 #include "WebPage.h"
33
34 using namespace WebKit;
35
36 WKTypeID WKBundlePageGetTypeID()
37 {
38     return toAPI(WebPage::APIType);
39 }
40
41 void WKBundlePageSetContextMenuClient(WKBundlePageRef pageRef, WKBundlePageContextMenuClient* wkClient)
42 {
43     if (wkClient && wkClient->version)
44         return;
45     toImpl(pageRef)->initializeInjectedBundleContextMenuClient(wkClient);
46 }
47
48 void WKBundlePageSetEditorClient(WKBundlePageRef pageRef, WKBundlePageEditorClient* wkClient)
49 {
50     if (wkClient && wkClient->version)
51         return;
52     toImpl(pageRef)->initializeInjectedBundleEditorClient(wkClient);
53 }
54
55 void WKBundlePageSetFormClient(WKBundlePageRef pageRef, WKBundlePageFormClient* wkClient)
56 {
57     if (wkClient && wkClient->version)
58         return;
59     toImpl(pageRef)->initializeInjectedBundleFormClient(wkClient);
60 }
61
62 void WKBundlePageSetLoaderClient(WKBundlePageRef pageRef, WKBundlePageLoaderClient* wkClient)
63 {
64     if (wkClient && wkClient->version)
65         return;
66     toImpl(pageRef)->initializeInjectedBundleLoaderClient(wkClient);
67 }
68
69 void WKBundlePageSetUIClient(WKBundlePageRef pageRef, WKBundlePageUIClient* wkClient)
70 {
71     if (wkClient && wkClient->version)
72         return;
73     toImpl(pageRef)->initializeInjectedBundleUIClient(wkClient);
74 }
75
76 WKBundleFrameRef WKBundlePageGetMainFrame(WKBundlePageRef pageRef)
77 {
78     return toAPI(toImpl(pageRef)->mainFrame());
79 }
80
81 void WKBundlePageStopLoading(WKBundlePageRef pageRef)
82 {
83     toImpl(pageRef)->stopLoading();
84 }
85
86 WKStringRef WKBundlePageCopyRenderTreeExternalRepresentation(WKBundlePageRef pageRef)
87 {
88     return toCopiedAPI(toImpl(pageRef)->renderTreeExternalRepresentation());
89 }
90
91 void WKBundlePageExecuteEditingCommand(WKBundlePageRef pageRef, WKStringRef name, WKStringRef argument)
92 {
93     toImpl(pageRef)->executeEditingCommand(toImpl(name)->string(), toImpl(argument)->string());
94 }
95
96 bool WKBundlePageIsEditingCommandEnabled(WKBundlePageRef pageRef, WKStringRef name)
97 {
98     return toImpl(pageRef)->isEditingCommandEnabled(toImpl(name)->string());
99 }
100
101 void WKBundlePageClearMainFrameName(WKBundlePageRef pageRef)
102 {
103     toImpl(pageRef)->clearMainFrameName();
104 }
105
106 void WKBundlePageClose(WKBundlePageRef pageRef)
107 {
108     toImpl(pageRef)->sendClose();
109 }
110
111 double WKBundlePageGetTextZoomFactor(WKBundlePageRef pageRef)
112 {
113     return toImpl(pageRef)->textZoomFactor();
114 }
115
116 void WKBundlePageSetTextZoomFactor(WKBundlePageRef pageRef, double zoomFactor)
117 {
118     toImpl(pageRef)->setTextZoomFactor(zoomFactor);
119 }
120
121 double WKBundlePageGetPageZoomFactor(WKBundlePageRef pageRef)
122 {
123     return toImpl(pageRef)->pageZoomFactor();
124 }
125
126 void WKBundlePageSetPageZoomFactor(WKBundlePageRef pageRef, double zoomFactor)
127 {
128     toImpl(pageRef)->setPageZoomFactor(zoomFactor);
129 }
130
131 WKBundleBackForwardListRef WKBundlePageGetBackForwardList(WKBundlePageRef pageRef)
132 {
133     return toAPI(toImpl(pageRef)->backForwardList());
134 }
135
136 void WKBundlePageInstallPageOverlay(WKBundlePageRef pageRef, WKBundlePageOverlayRef pageOverlayRef)
137 {
138     toImpl(pageRef)->installPageOverlay(toImpl(pageOverlayRef));
139 }
140
141 void WKBundlePageUninstallPageOverlay(WKBundlePageRef pageRef, WKBundlePageOverlayRef pageOverlayRef)
142 {
143     toImpl(pageRef)->uninstallPageOverlay(toImpl(pageOverlayRef));
144 }