 Chromium Code Reviews
 Chromium Code Reviews Issue 2927703003:
  Move ObjectContentType entirely to HTMLPlugInElement  (Closed)
    
  
    Issue 2927703003:
  Move ObjectContentType entirely to HTMLPlugInElement  (Closed) 
  | 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, 2007, 2008, 2009, 2011 Apple Inc. All rights | 5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011 Apple Inc. All rights | 
| 6 * reserved. | 6 * reserved. | 
| 7 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) | 7 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) | 
| 8 * | 8 * | 
| 9 * This library is free software; you can redistribute it and/or | 9 * This library is free software; you can redistribute it and/or | 
| 10 * modify it under the terms of the GNU Library General Public | 10 * modify it under the terms of the GNU Library General Public | 
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 141 | 141 | 
| 142 if (src_index == -1 && data_index != -1) { | 142 if (src_index == -1 && data_index != -1) { | 
| 143 param_names->push_back("src"); | 143 param_names->push_back("src"); | 
| 144 param_values->push_back((*param_values)[data_index]); | 144 param_values->push_back((*param_values)[data_index]); | 
| 145 } | 145 } | 
| 146 } | 146 } | 
| 147 | 147 | 
| 148 // TODO(schenney): crbug.com/572908 This function should not deal with url or | 148 // TODO(schenney): crbug.com/572908 This function should not deal with url or | 
| 149 // serviceType! | 149 // serviceType! | 
| 150 void HTMLObjectElement::ParametersForPlugin(Vector<String>& param_names, | 150 void HTMLObjectElement::ParametersForPlugin(Vector<String>& param_names, | 
| 151 Vector<String>& param_values, | 151 Vector<String>& param_values) { | 
| 152 String& url, | |
| 153 String& service_type) { | |
| 154 HashSet<StringImpl*, CaseFoldingHash> unique_param_names; | 152 HashSet<StringImpl*, CaseFoldingHash> unique_param_names; | 
| 155 String url_parameter; | |
| 156 | 153 | 
| 157 // Scan the PARAM children and store their name/value pairs. | 154 // Scan the PARAM children and store their name/value pairs. | 
| 158 // Get the URL and type from the params if we don't already have them. | 155 // Get the URL and type from the params if we don't already have them. | 
| 159 for (HTMLParamElement* p = Traversal<HTMLParamElement>::FirstChild(*this); p; | 156 for (HTMLParamElement* p = Traversal<HTMLParamElement>::FirstChild(*this); p; | 
| 160 p = Traversal<HTMLParamElement>::NextSibling(*p)) { | 157 p = Traversal<HTMLParamElement>::NextSibling(*p)) { | 
| 161 String name = p->GetName(); | 158 String name = p->GetName(); | 
| 162 if (name.IsEmpty()) | 159 if (name.IsEmpty()) | 
| 163 continue; | 160 continue; | 
| 164 | 161 | 
| 165 unique_param_names.insert(name.Impl()); | 162 unique_param_names.insert(name.Impl()); | 
| 166 param_names.push_back(p->GetName()); | 163 param_names.push_back(p->GetName()); | 
| 167 param_values.push_back(p->Value()); | 164 param_values.push_back(p->Value()); | 
| 168 | 165 | 
| 169 // TODO(schenney): crbug.com/572908 url adjustment does not belong in this | 166 // TODO(schenney): crbug.com/572908 url adjustment does not belong in this | 
| 170 // function. | 167 // function. | 
| 171 if (url.IsEmpty() && url_parameter.IsEmpty() && | 168 // HTML5 says that an object resource's URL is specified by the object's | 
| 172 (DeprecatedEqualIgnoringCase(name, "src") || | 169 // data attribute, not by a param element. However, for compatibility, allow | 
| 173 DeprecatedEqualIgnoringCase(name, "movie") || | 170 // the resource's URL to be given by a param named "src", "movie", "code" or | 
| 174 DeprecatedEqualIgnoringCase(name, "code") || | 171 // "url" if we know that resource points to a plugin. | 
| 175 DeprecatedEqualIgnoringCase(name, "url"))) | 172 if (url_.IsEmpty() && (DeprecatedEqualIgnoringCase(name, "src") || | 
| 176 url_parameter = StripLeadingAndTrailingHTMLSpaces(p->Value()); | 173 DeprecatedEqualIgnoringCase(name, "movie") || | 
| 174 DeprecatedEqualIgnoringCase(name, "code") || | |
| 175 DeprecatedEqualIgnoringCase(name, "url"))) { | |
| 176 url_ = StripLeadingAndTrailingHTMLSpaces(p->Value()); | |
| 177 } | |
| 177 // TODO(schenney): crbug.com/572908 serviceType calculation does not belong | 178 // TODO(schenney): crbug.com/572908 serviceType calculation does not belong | 
| 178 // in this function. | 179 // in this function. | 
| 179 if (service_type.IsEmpty() && DeprecatedEqualIgnoringCase(name, "type")) { | 180 if (service_type_.IsEmpty() && DeprecatedEqualIgnoringCase(name, "type")) { | 
| 180 service_type = p->Value(); | 181 size_t pos = p->Value().Find(";"); | 
| 181 size_t pos = service_type.Find(";"); | |
| 182 if (pos != kNotFound) | 182 if (pos != kNotFound) | 
| 183 service_type = service_type.Left(pos); | 183 service_type_ = p->Value().GetString().Left(pos); | 
| 184 } | 184 } | 
| 185 } | 185 } | 
| 186 | 186 | 
| 187 // When OBJECT is used for an applet via Sun's Java plugin, the CODEBASE | |
| 188 // attribute in the tag points to the Java plugin itself (an ActiveX | |
| 189 // component) while the actual applet CODEBASE is in a PARAM tag. See | |
| 190 // <http://java.sun.com/products/plugin/1.2/docs/tags.html>. This means we | |
| 191 // have to explicitly suppress the tag's CODEBASE attribute if there is none | |
| 192 // in a PARAM, else our Java plugin will misinterpret it. [4004531] | |
| 193 String codebase; | |
| 194 if (MIMETypeRegistry::IsJavaAppletMIMEType(service_type)) { | |
| 
Nate Chapin
2017/06/08 18:07:02
This should be unnecessary now that we never insta
 | |
| 195 codebase = "codebase"; | |
| 196 unique_param_names.insert( | |
| 197 codebase.Impl()); // pretend we found it in a PARAM already | |
| 198 } | |
| 199 | |
| 200 // Turn the attributes of the <object> element into arrays, but don't override | 187 // Turn the attributes of the <object> element into arrays, but don't override | 
| 201 // <param> values. | 188 // <param> values. | 
| 202 AttributeCollection attributes = this->Attributes(); | 189 AttributeCollection attributes = this->Attributes(); | 
| 203 for (const Attribute& attribute : attributes) { | 190 for (const Attribute& attribute : attributes) { | 
| 204 const AtomicString& name = attribute.GetName().LocalName(); | 191 const AtomicString& name = attribute.GetName().LocalName(); | 
| 205 if (!unique_param_names.Contains(name.Impl())) { | 192 if (!unique_param_names.Contains(name.Impl())) { | 
| 206 param_names.push_back(name.GetString()); | 193 param_names.push_back(name.GetString()); | 
| 207 param_values.push_back(attribute.Value().GetString()); | 194 param_values.push_back(attribute.Value().GetString()); | 
| 208 } | 195 } | 
| 209 } | 196 } | 
| 210 | 197 | 
| 211 MapDataParamToSrc(¶m_names, ¶m_values); | 198 MapDataParamToSrc(¶m_names, ¶m_values); | 
| 212 | |
| 213 // HTML5 says that an object resource's URL is specified by the object's data | |
| 214 // attribute, not by a param element. However, for compatibility, allow the | |
| 215 // resource's URL to be given by a param named "src", "movie", "code" or "url" | |
| 216 // if we know that resource points to a plugin. | |
| 217 if (url.IsEmpty() && !url_parameter.IsEmpty()) { | |
| 218 KURL completed_url = GetDocument().CompleteURL(url_parameter); | |
| 219 bool use_fallback; | |
| 220 if (ShouldUsePlugin(completed_url, service_type, false, use_fallback)) | |
| 
Nate Chapin
2017/06/08 18:07:02
I can't find any evidence that we need to check Sh
 | |
| 221 url = url_parameter; | |
| 222 } | |
| 223 } | 199 } | 
| 224 | 200 | 
| 225 bool HTMLObjectElement::HasFallbackContent() const { | 201 bool HTMLObjectElement::HasFallbackContent() const { | 
| 226 for (Node* child = firstChild(); child; child = child->nextSibling()) { | 202 for (Node* child = firstChild(); child; child = child->nextSibling()) { | 
| 227 // Ignore whitespace-only text, and <param> tags, any other content is | 203 // Ignore whitespace-only text, and <param> tags, any other content is | 
| 228 // fallback content. | 204 // fallback content. | 
| 229 if (child->IsTextNode()) { | 205 if (child->IsTextNode()) { | 
| 230 if (!ToText(child)->ContainsOnlyWhitespace()) | 206 if (!ToText(child)->ContainsOnlyWhitespace()) | 
| 231 return true; | 207 return true; | 
| 232 } else if (!isHTMLParamElement(*child)) { | 208 } else if (!isHTMLParamElement(*child)) { | 
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 285 } | 261 } | 
| 286 | 262 | 
| 287 // TODO(schenney): crbug.com/572908 I'm not sure it's ever possible to get | 263 // TODO(schenney): crbug.com/572908 I'm not sure it's ever possible to get | 
| 288 // into updateWidget during a removal, but just in case we should avoid | 264 // into updateWidget during a removal, but just in case we should avoid | 
| 289 // loading the frame to prevent security bugs. | 265 // loading the frame to prevent security bugs. | 
| 290 if (!SubframeLoadingDisabler::CanLoadFrame(*this)) { | 266 if (!SubframeLoadingDisabler::CanLoadFrame(*this)) { | 
| 291 DispatchErrorEvent(); | 267 DispatchErrorEvent(); | 
| 292 return; | 268 return; | 
| 293 } | 269 } | 
| 294 | 270 | 
| 295 String url = this->Url(); | |
| 296 String service_type = service_type_; | |
| 297 | |
| 298 // TODO(schenney): crbug.com/572908 These should be joined into a | 271 // TODO(schenney): crbug.com/572908 These should be joined into a | 
| 299 // PluginParameters class. | 272 // PluginParameters class. | 
| 300 Vector<String> param_names; | 273 Vector<String> param_names; | 
| 301 Vector<String> param_values; | 274 Vector<String> param_values; | 
| 302 ParametersForPlugin(param_names, param_values, url, service_type); | 275 ParametersForPlugin(param_names, param_values); | 
| 303 | 276 | 
| 304 // Note: url is modified above by parametersForPlugin. | 277 // Note: url is modified above by parametersForPlugin. | 
| 305 if (!AllowedToLoadFrameURL(url)) { | 278 if (!AllowedToLoadFrameURL(url_)) { | 
| 306 DispatchErrorEvent(); | 279 DispatchErrorEvent(); | 
| 307 return; | 280 return; | 
| 308 } | 281 } | 
| 309 | 282 | 
| 310 // TODO(schenney): crbug.com/572908 Is it possible to get here without a | 283 // TODO(schenney): crbug.com/572908 Is it possible to get here without a | 
| 311 // layoutObject now that we don't have beforeload events? | 284 // layoutObject now that we don't have beforeload events? | 
| 312 if (!GetLayoutObject()) | 285 if (!GetLayoutObject()) | 
| 313 return; | 286 return; | 
| 314 | 287 | 
| 315 // Overwrites the URL and MIME type of a Flash embed to use an HTML5 embed. | 288 // Overwrites the URL and MIME type of a Flash embed to use an HTML5 embed. | 
| 316 KURL overriden_url = | 289 KURL overriden_url = | 
| 317 GetDocument().GetFrame()->Loader().Client()->OverrideFlashEmbedWithHTML( | 290 GetDocument().GetFrame()->Loader().Client()->OverrideFlashEmbedWithHTML( | 
| 318 GetDocument().CompleteURL(url_)); | 291 GetDocument().CompleteURL(url_)); | 
| 319 if (!overriden_url.IsEmpty()) { | 292 if (!overriden_url.IsEmpty()) { | 
| 320 url = url_ = overriden_url.GetString(); | 293 url_ = overriden_url.GetString(); | 
| 321 service_type = service_type_ = "text/html"; | 294 service_type_ = "text/html"; | 
| 322 } | 295 } | 
| 323 | 296 | 
| 324 if (!HasValidClassId() || | 297 if (!HasValidClassId() || !RequestObject(param_names, param_values)) { | 
| 325 !RequestObject(url, service_type, param_names, param_values)) { | 298 if (!url_.IsEmpty()) | 
| 326 if (!url.IsEmpty()) | |
| 327 DispatchErrorEvent(); | 299 DispatchErrorEvent(); | 
| 328 if (HasFallbackContent()) | 300 if (HasFallbackContent()) | 
| 329 RenderFallbackContent(); | 301 RenderFallbackContent(); | 
| 330 } else { | 302 } else { | 
| 331 if (IsErrorplaceholder()) | 303 if (IsErrorplaceholder()) | 
| 332 DispatchErrorEvent(); | 304 DispatchErrorEvent(); | 
| 333 } | 305 } | 
| 334 } | 306 } | 
| 335 | 307 | 
| 336 Node::InsertionNotificationRequest HTMLObjectElement::InsertedInto( | 308 Node::InsertionNotificationRequest HTMLObjectElement::InsertedInto( | 
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 465 | 437 | 
| 466 bool HTMLObjectElement::WillUseFallbackContentAtLayout() const { | 438 bool HTMLObjectElement::WillUseFallbackContentAtLayout() const { | 
| 467 return !HasValidClassId() && HasFallbackContent(); | 439 return !HasValidClassId() && HasFallbackContent(); | 
| 468 } | 440 } | 
| 469 | 441 | 
| 470 void HTMLObjectElement::AssociateWith(HTMLFormElement* form) { | 442 void HTMLObjectElement::AssociateWith(HTMLFormElement* form) { | 
| 471 AssociateByParser(form); | 443 AssociateByParser(form); | 
| 472 }; | 444 }; | 
| 473 | 445 | 
| 474 } // namespace blink | 446 } // namespace blink | 
| OLD | NEW |