OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
4 * (C) 2000 Stefan Schimanski (1Stein@gmx.de) | 4 * (C) 2000 Stefan Schimanski (1Stein@gmx.de) |
5 * Copyright (C) 2004, 2005, 2006, 2008, 2009, 2012 Apple Inc. All rights reserv ed. | 5 * Copyright (C) 2004, 2005, 2006, 2008, 2009, 2012 Apple Inc. All rights reserv ed. |
6 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) | 6 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) |
7 * | 7 * |
8 * This library is free software; you can redistribute it and/or | 8 * This library is free software; you can redistribute it and/or |
9 * modify it under the terms of the GNU Library General Public | 9 * modify it under the terms of the GNU Library General Public |
10 * License as published by the Free Software Foundation; either | 10 * License as published by the Free Software Foundation; either |
11 * version 2 of the License, or (at your option) any later version. | 11 * version 2 of the License, or (at your option) any later version. |
12 * | 12 * |
13 * This library is distributed in the hope that it will be useful, | 13 * This library is distributed in the hope that it will be useful, |
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
16 * Library General Public License for more details. | 16 * Library General Public License for more details. |
17 * | 17 * |
18 * You should have received a copy of the GNU Library General Public License | 18 * You should have received a copy of the GNU Library General Public License |
19 * along with this library; see the file COPYING.LIB. If not, write to | 19 * along with this library; see the file COPYING.LIB. If not, write to |
20 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 20 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
21 * Boston, MA 02110-1301, USA. | 21 * Boston, MA 02110-1301, USA. |
22 */ | 22 */ |
23 | 23 |
24 #include "config.h" | 24 #include "config.h" |
25 #include "core/html/HTMLAppletElement.h" | 25 #include "core/html/HTMLAppletElement.h" |
26 | 26 |
27 #include "HTMLNames.h" | 27 #include "HTMLNames.h" |
28 #include "core/html/HTMLParamElement.h" | 28 #include "core/html/HTMLParamElement.h" |
29 #include "core/loader/FrameLoader.h" | 29 #include "core/loader/FrameLoader.h" |
30 #include "core/loader/FrameLoaderClient.h" | |
31 #include "core/page/ContentSecurityPolicy.h" | |
30 #include "core/page/Frame.h" | 32 #include "core/page/Frame.h" |
31 #include "core/page/Settings.h" | 33 #include "core/page/Settings.h" |
32 #include "core/platform/Widget.h" | 34 #include "core/platform/Widget.h" |
33 #include "core/rendering/RenderApplet.h" | 35 #include "core/rendering/RenderApplet.h" |
36 #include "weborigin/SecurityOrigin.h" | |
34 | 37 |
35 namespace WebCore { | 38 namespace WebCore { |
36 | 39 |
37 using namespace HTMLNames; | 40 using namespace HTMLNames; |
38 | 41 |
39 HTMLAppletElement::HTMLAppletElement(const QualifiedName& tagName, Document* doc ument, bool createdByParser) | 42 HTMLAppletElement::HTMLAppletElement(const QualifiedName& tagName, Document* doc ument, bool createdByParser) |
40 : HTMLPlugInImageElement(tagName, document, createdByParser, ShouldNotPrefer PlugInsForImages) | 43 : HTMLPlugInImageElement(tagName, document, createdByParser, ShouldNotPrefer PlugInsForImages) |
41 { | 44 { |
42 ASSERT(hasTagName(appletTag)); | 45 ASSERT(hasTagName(appletTag)); |
43 ScriptWrappable::init(this); | 46 ScriptWrappable::init(this); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
91 | 94 |
92 void HTMLAppletElement::updateWidget(PluginCreationOption) | 95 void HTMLAppletElement::updateWidget(PluginCreationOption) |
93 { | 96 { |
94 setNeedsWidgetUpdate(false); | 97 setNeedsWidgetUpdate(false); |
95 // FIXME: This should ASSERT isFinishedParsingChildren() instead. | 98 // FIXME: This should ASSERT isFinishedParsingChildren() instead. |
96 if (!isFinishedParsingChildren()) | 99 if (!isFinishedParsingChildren()) |
97 return; | 100 return; |
98 | 101 |
99 RenderEmbeddedObject* renderer = renderEmbeddedObject(); | 102 RenderEmbeddedObject* renderer = renderEmbeddedObject(); |
100 | 103 |
104 Frame* frame = document()->frame(); | |
105 ASSERT(frame); | |
106 | |
101 LayoutUnit contentWidth = renderer->style()->width().isFixed() ? LayoutUnit( renderer->style()->width().value()) : | 107 LayoutUnit contentWidth = renderer->style()->width().isFixed() ? LayoutUnit( renderer->style()->width().value()) : |
102 renderer->width() - renderer->borderAndPaddingWidth(); | 108 renderer->width() - renderer->borderAndPaddingWidth(); |
103 LayoutUnit contentHeight = renderer->style()->height().isFixed() ? LayoutUni t(renderer->style()->height().value()) : | 109 LayoutUnit contentHeight = renderer->style()->height().isFixed() ? LayoutUni t(renderer->style()->height().value()) : |
104 renderer->height() - renderer->borderAndPaddingHeight(); | 110 renderer->height() - renderer->borderAndPaddingHeight(); |
105 | 111 |
106 Vector<String> paramNames; | 112 Vector<String> paramNames; |
107 Vector<String> paramValues; | 113 Vector<String> paramValues; |
108 | 114 |
109 paramNames.append("code"); | 115 paramNames.append("code"); |
110 paramValues.append(getAttribute(codeAttr).string()); | 116 paramValues.append(getAttribute(codeAttr).string()); |
111 | 117 |
112 const AtomicString& codeBase = getAttribute(codebaseAttr); | 118 const AtomicString& codeBase = getAttribute(codebaseAttr); |
113 if (!codeBase.isNull()) { | 119 if (!codeBase.isNull()) { |
120 KURL codeBaseURL = document()->completeURL(codeBase); | |
121 if (!document()->securityOrigin()->canDisplay(codeBaseURL)) { | |
122 FrameLoader::reportLocalLoadFailed(frame, codeBaseURL.string()); | |
123 return; | |
124 } | |
125 const char javaAppletMimeType[] = "application/x-java-applet"; | |
126 if (!document()->contentSecurityPolicy()->allowObjectFromSource(codeBase URL) | |
127 || !document()->contentSecurityPolicy()->allowPluginType(javaAppletM imeType, javaAppletMimeType, codeBaseURL)) | |
128 return; | |
114 paramNames.append("codeBase"); | 129 paramNames.append("codeBase"); |
115 paramValues.append(codeBase.string()); | 130 paramValues.append(codeBase.string()); |
116 } | 131 } |
117 | 132 |
118 const AtomicString& name = document()->isHTMLDocument() ? getNameAttribute() : getIdAttribute(); | 133 const AtomicString& name = document()->isHTMLDocument() ? getNameAttribute() : getIdAttribute(); |
119 if (!name.isNull()) { | 134 if (!name.isNull()) { |
120 paramNames.append("name"); | 135 paramNames.append("name"); |
121 paramValues.append(name.string()); | 136 paramValues.append(name.string()); |
122 } | 137 } |
123 | 138 |
124 const AtomicString& archive = getAttribute(archiveAttr); | 139 const AtomicString& archive = getAttribute(archiveAttr); |
125 if (!archive.isNull()) { | 140 if (!archive.isNull()) { |
126 paramNames.append("archive"); | 141 paramNames.append("archive"); |
127 paramValues.append(archive.string()); | 142 paramValues.append(archive.string()); |
128 } | 143 } |
129 | 144 |
130 paramNames.append("baseURL"); | 145 paramNames.append("baseURL"); |
131 paramValues.append(document()->baseURL().string()); | 146 const KURL& baseURL = document()->baseURL(); |
abarth-chromium
2013/07/27 00:16:28
"const KURL&" -> KURL
There's no way saving the
| |
147 paramValues.append(baseURL.string()); | |
132 | 148 |
133 const AtomicString& mayScript = getAttribute(mayscriptAttr); | 149 const AtomicString& mayScript = getAttribute(mayscriptAttr); |
134 if (!mayScript.isNull()) { | 150 if (!mayScript.isNull()) { |
135 paramNames.append("mayScript"); | 151 paramNames.append("mayScript"); |
136 paramValues.append(mayScript.string()); | 152 paramValues.append(mayScript.string()); |
137 } | 153 } |
138 | 154 |
139 for (Node* child = firstChild(); child; child = child->nextSibling()) { | 155 for (Node* child = firstChild(); child; child = child->nextSibling()) { |
140 if (!child->hasTagName(paramTag)) | 156 if (!child->hasTagName(paramTag)) |
141 continue; | 157 continue; |
142 | 158 |
143 HTMLParamElement* param = static_cast<HTMLParamElement*>(child); | 159 HTMLParamElement* param = static_cast<HTMLParamElement*>(child); |
144 if (param->name().isEmpty()) | 160 if (param->name().isEmpty()) |
145 continue; | 161 continue; |
146 | 162 |
147 paramNames.append(param->name()); | 163 paramNames.append(param->name()); |
148 paramValues.append(param->value()); | 164 paramValues.append(param->value()); |
149 } | 165 } |
150 | 166 |
151 Frame* frame = document()->frame(); | 167 RefPtr<Widget> widget; |
152 ASSERT(frame); | 168 if (frame->loader()->subframeLoader()->allowPlugins(AboutToInstantiatePlugin )) |
169 widget = frame->loader()->client()->createJavaAppletWidget(roundedIntSiz e(LayoutSize(contentWidth, contentHeight)), this, baseURL, paramNames, paramValu es); | |
153 | 170 |
154 renderer->setWidget(frame->loader()->subframeLoader()->createJavaAppletWidge t(roundedIntSize(LayoutSize(contentWidth, contentHeight)), this, paramNames, par amValues)); | 171 if (!widget) { |
172 if (!renderer->showsUnavailablePluginIndicator()) | |
173 renderer->setPluginUnavailabilityReason(RenderEmbeddedObject::Plugin Missing); | |
174 return; | |
175 } | |
176 frame->loader()->subframeLoader()->setContainsPlugins(); | |
177 renderer->setWidget(widget); | |
155 } | 178 } |
156 | 179 |
157 bool HTMLAppletElement::canEmbedJava() const | 180 bool HTMLAppletElement::canEmbedJava() const |
158 { | 181 { |
159 if (document()->isSandboxed(SandboxPlugins)) | 182 if (document()->isSandboxed(SandboxPlugins)) |
160 return false; | 183 return false; |
161 | 184 |
162 Settings* settings = document()->settings(); | 185 Settings* settings = document()->settings(); |
163 if (!settings) | 186 if (!settings) |
164 return false; | 187 return false; |
165 | 188 |
166 if (!settings->isJavaEnabled()) | 189 if (!settings->isJavaEnabled()) |
167 return false; | 190 return false; |
168 | 191 |
169 return true; | 192 return true; |
170 } | 193 } |
171 | 194 |
172 } | 195 } |
OLD | NEW |