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, 2011 Apple Inc. All rights reserv ed. | 5 * Copyright (C) 2004, 2005, 2006, 2008, 2009, 2011 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 |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
139 | 139 |
140 // FIXME: These should be joined into a PluginParameters class. | 140 // FIXME: These should be joined into a PluginParameters class. |
141 Vector<String> paramNames; | 141 Vector<String> paramNames; |
142 Vector<String> paramValues; | 142 Vector<String> paramValues; |
143 parametersForPlugin(paramNames, paramValues); | 143 parametersForPlugin(paramNames, paramValues); |
144 | 144 |
145 // FIXME: Can we not have layoutObject here now that beforeload events are g one? | 145 // FIXME: Can we not have layoutObject here now that beforeload events are g one? |
146 if (!layoutObject()) | 146 if (!layoutObject()) |
147 return; | 147 return; |
148 | 148 |
149 // If necessary (and possible), we will rewrite a YouTube Flash embed | |
150 // to use HTML5 instead. | |
151 KURL url = KURL(ParsedURLStringTag(), m_url); | |
Mike West
2016/07/12 13:56:08
Nit: `s/ParsedURLStringTag()/ParsedURLString/`.
N
| |
152 String base = SecurityOrigin::create(url)->domain(); | |
153 | |
154 // If the site is going to be accessing the YouTube Flash player using the | |
155 // JS APIs, we don't want to modify the player. | |
156 if (m_url.find("enablejsapi=1") == (size_t) -1 | |
157 && rewriteYouTubeFlashEmbeds(base) && url.path().startsWith("/v/")) { | |
158 | |
159 // If the website is using an invalid YouTube URL, we'll try and | |
160 // fix the url by ensuring that IF there are multiple parameters, | |
161 // the parameter string begins with a "?" and then follows with "&" | |
162 // for each subsequent parameter. | |
163 size_t indexAmp = m_url.find("&"); | |
164 bool invalidUrl = false; | |
165 size_t indexQm = m_url.find("?"); | |
166 | |
167 if (indexQm == (size_t) -1 || indexQm > indexAmp) { | |
168 invalidUrl = true; | |
169 } | |
170 | |
171 if (invalidUrl) { | |
172 m_url.replace("?", "&"); | |
173 m_url.replace(indexAmp, 1, "?"); | |
174 } | |
175 | |
176 m_url.replace("/v/", "/embed/"); | |
177 m_serviceType = "text/html"; | |
178 } | |
179 | |
149 requestObject(m_url, m_serviceType, paramNames, paramValues); | 180 requestObject(m_url, m_serviceType, paramNames, paramValues); |
150 } | 181 } |
151 | 182 |
183 bool HTMLEmbedElement::rewriteYouTubeFlashEmbeds(String const & baseUrl) | |
184 { | |
185 if (baseUrl == String("www.youtube.com")) { | |
186 return true; | |
187 } | |
188 return false; | |
189 } | |
190 | |
152 bool HTMLEmbedElement::layoutObjectIsNeeded(const ComputedStyle& style) | 191 bool HTMLEmbedElement::layoutObjectIsNeeded(const ComputedStyle& style) |
153 { | 192 { |
154 if (isImageType()) | 193 if (isImageType()) |
155 return HTMLPlugInElement::layoutObjectIsNeeded(style); | 194 return HTMLPlugInElement::layoutObjectIsNeeded(style); |
156 | 195 |
157 // https://html.spec.whatwg.org/multipage/embedded-content.html#the-embed-el ement | 196 // https://html.spec.whatwg.org/multipage/embedded-content.html#the-embed-el ement |
158 // While any of the following conditions are occurring, any plugin | 197 // While any of the following conditions are occurring, any plugin |
159 // instantiated for the element must be removed, and the embed element | 198 // instantiated for the element must be removed, and the embed element |
160 // represents nothing: | 199 // represents nothing: |
161 | 200 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
198 { | 237 { |
199 // http://www.whatwg.org/specs/web-apps/current-work/#exposed | 238 // http://www.whatwg.org/specs/web-apps/current-work/#exposed |
200 for (HTMLObjectElement* object = Traversal<HTMLObjectElement>::firstAncestor (*this); object; object = Traversal<HTMLObjectElement>::firstAncestor(*object)) { | 239 for (HTMLObjectElement* object = Traversal<HTMLObjectElement>::firstAncestor (*this); object; object = Traversal<HTMLObjectElement>::firstAncestor(*object)) { |
201 if (object->isExposed()) | 240 if (object->isExposed()) |
202 return false; | 241 return false; |
203 } | 242 } |
204 return true; | 243 return true; |
205 } | 244 } |
206 | 245 |
207 } // namespace blink | 246 } // namespace blink |
OLD | NEW |