|
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 "WKFrame.h" |
|
27 |
|
28 #include "WKAPICast.h" |
|
29 #include "WebFrameProxy.h" |
|
30 |
|
31 using namespace WebKit; |
|
32 |
|
33 bool WKFrameIsMainFrame(WKFrameRef frameRef) |
|
34 { |
|
35 WebFrameProxy* frame = toWK(frameRef); |
|
36 return frame->isMainFrame(); |
|
37 } |
|
38 |
|
39 WKFrameLoadState WKFrameGetFrameLoadState(WKFrameRef frameRef) |
|
40 { |
|
41 WebFrameProxy* frame = toWK(frameRef); |
|
42 switch (frame->loadState()) { |
|
43 case WebFrameProxy::LoadStateProvisional: |
|
44 return kWKFrameLoadStateProvisional; |
|
45 case WebFrameProxy::LoadStateCommitted: |
|
46 return kWKFrameLoadStateCommitted; |
|
47 case WebFrameProxy::LoadStateFinished: |
|
48 return kWKFrameLoadStateFinished; |
|
49 } |
|
50 |
|
51 ASSERT_NOT_REACHED(); |
|
52 return kWKFrameLoadStateFinished; |
|
53 } |
|
54 |
|
55 WKURLRef WKFrameGetProvisionalURL(WKFrameRef frameRef) |
|
56 { |
|
57 WebFrameProxy* frame = toWK(frameRef); |
|
58 return toURLRef(frame->provisionalURL().impl()); |
|
59 } |
|
60 |
|
61 WKURLRef WKFrameGetURL(WKFrameRef frameRef) |
|
62 { |
|
63 WebFrameProxy* frame = toWK(frameRef); |
|
64 return toURLRef(frame->url().impl()); |
|
65 } |
|
66 |
|
67 WKPageRef WKFrameGetPage(WKFrameRef frameRef) |
|
68 { |
|
69 WebFrameProxy* frame = toWK(frameRef); |
|
70 return toRef(frame->page()); |
|
71 } |
|
72 |
|
73 WKFrameRef WKFrameRetain(WKFrameRef frameRef) |
|
74 { |
|
75 WebFrameProxy* frame = toWK(frameRef); |
|
76 frame->ref(); |
|
77 return frameRef; |
|
78 } |
|
79 |
|
80 void WKFrameRelease(WKFrameRef frameRef) |
|
81 { |
|
82 WebFrameProxy* frame = toWK(frameRef); |
|
83 frame->deref(); |
|
84 } |