Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / platform / exported / WebPrerender.cpp
1 /*
2  * Copyright (C) 2012 Google 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 are
6  * met:
7  *
8  *     * Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  *     * Redistributions in binary form must reproduce the above
11  * copyright notice, this list of conditions and the following disclaimer
12  * in the documentation and/or other materials provided with the
13  * distribution.
14  *     * Neither the name of Google Inc. nor the names of its
15  * contributors may be used to endorse or promote products derived from
16  * this software without specific prior written permission.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29  */
30
31 #include "config.h"
32 #include "public/platform/WebPrerender.h"
33
34 #include "platform/Prerender.h"
35 #include "wtf/PassRefPtr.h"
36
37 namespace blink {
38
39 namespace {
40
41 class ExtraDataContainer : public WebCore::Prerender::ExtraData {
42 public:
43     static PassRefPtr<ExtraDataContainer> create(WebPrerender::ExtraData* extraData) { return adoptRef(new ExtraDataContainer(extraData)); }
44
45     virtual ~ExtraDataContainer() { }
46
47     WebPrerender::ExtraData* extraData() const { return m_extraData.get(); }
48
49 private:
50     explicit ExtraDataContainer(WebPrerender::ExtraData* extraData)
51         : m_extraData(adoptPtr(extraData))
52     {
53     }
54
55     OwnPtr<WebPrerender::ExtraData> m_extraData;
56 };
57
58 } // anon namespace
59
60 WebPrerender::WebPrerender(PassRefPtr<WebCore::Prerender> prerender)
61     : m_private(prerender)
62 {
63 }
64
65 const WebCore::Prerender* WebPrerender::toPrerender() const
66 {
67     return m_private.get();
68 }
69
70 void WebPrerender::reset()
71 {
72     m_private.reset();
73 }
74
75 void WebPrerender::assign(const WebPrerender& other)
76 {
77     m_private = other.m_private;
78 }
79
80 bool WebPrerender::isNull() const
81 {
82     return m_private.isNull();
83 }
84
85 WebURL WebPrerender::url() const
86 {
87     return WebURL(m_private->url());
88 }
89
90 unsigned WebPrerender::relTypes() const
91 {
92     return m_private->relTypes();
93 }
94
95 WebString WebPrerender::referrer() const
96 {
97     return m_private->referrer();
98 }
99
100 WebReferrerPolicy WebPrerender::referrerPolicy() const
101 {
102     return static_cast<WebReferrerPolicy>(m_private->referrerPolicy());
103 }
104
105 void WebPrerender::setExtraData(WebPrerender::ExtraData* extraData)
106 {
107     m_private->setExtraData(ExtraDataContainer::create(extraData));
108 }
109
110 const WebPrerender::ExtraData* WebPrerender::extraData() const
111 {
112     RefPtr<WebCore::Prerender::ExtraData> webcoreExtraData = m_private->extraData();
113     if (!webcoreExtraData)
114         return 0;
115     return static_cast<ExtraDataContainer*>(webcoreExtraData.get())->extraData();
116 }
117
118 void WebPrerender::didStartPrerender()
119 {
120     m_private->didStartPrerender();
121 }
122
123 void WebPrerender::didStopPrerender()
124 {
125     m_private->didStopPrerender();
126 }
127
128 void WebPrerender::didSendLoadForPrerender()
129 {
130     m_private->didSendLoadForPrerender();
131 }
132
133 void WebPrerender::didSendDOMContentLoadedForPrerender()
134 {
135     m_private->didSendDOMContentLoadedForPrerender();
136 }
137
138 } // namespace blink