Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(288)

Side by Side Diff: Source/core/html/shadow/PluginPlaceholderElement.cpp

Issue 516273002: Move plugin placeholder style to CSS, and allow it to bypass main world CSP. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: add the actual .css file Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "config.h" 5 #include "config.h"
6 #include "core/html/shadow/PluginPlaceholderElement.h" 6 #include "core/html/shadow/PluginPlaceholderElement.h"
7 7
8 #include "bindings/core/v8/ExceptionState.h" 8 #include "bindings/core/v8/ExceptionState.h"
9 #include "bindings/core/v8/ScriptController.h"
9 #include "core/CSSPropertyNames.h" 10 #include "core/CSSPropertyNames.h"
10 #include "core/CSSValueKeywords.h" 11 #include "core/CSSValueKeywords.h"
12 #include "core/UserAgentStyleSheets.h"
13 #include "core/dom/Document.h"
14 #include "core/frame/LocalFrame.h"
15 #include "core/html/HTMLStyleElement.h"
16 #include "platform/ScriptForbiddenScope.h"
11 #include "wtf/StdLibExtras.h" 17 #include "wtf/StdLibExtras.h"
12 #include "wtf/text/AtomicString.h" 18 #include "wtf/text/AtomicString.h"
13 19
14 namespace blink { 20 namespace blink {
15 21
16 PluginPlaceholderElement::PluginPlaceholderElement(Document& document) 22 PluginPlaceholderElement::PluginPlaceholderElement(Document& document)
17 : HTMLDivElement(document) 23 : HTMLDivElement(document)
18 { 24 {
19 } 25 }
20 26
(...skipping 21 matching lines...) Expand all
42 bool PluginPlaceholderElement::initializePlaceholderElements() 48 bool PluginPlaceholderElement::initializePlaceholderElements()
43 { 49 {
44 // Produces DOM roughly equivalent to the following HTML: 50 // Produces DOM roughly equivalent to the following HTML:
45 // 51 //
46 // <div id="plugin-placeholder"> 52 // <div id="plugin-placeholder">
47 // <div id="plugin-placeholder-content"> 53 // <div id="plugin-placeholder-content">
48 // <div id="plugin-placeholder-message"></div> 54 // <div id="plugin-placeholder-message"></div>
49 // </div> 55 // </div>
50 // </div> 56 // </div>
51 57
52 // FIXME: Move style out of C++ and into CSS. 58 if (!document().frame())
59 return false;
53 60
61 ScriptForbiddenScope forbidScript;
62 ScriptController::BypassMainWorldCSP bypassCSP(document().frame()->script()) ;
54 TrackExceptionState exceptionState; 63 TrackExceptionState exceptionState;
55 64
56 DEFINE_STATIC_LOCAL(AtomicString, id, ("plugin-placeholder")); 65 DEFINE_STATIC_LOCAL(AtomicString, id, ("plugin-placeholder"));
57 setIdAttribute(id); 66 setIdAttribute(id);
58 setInlineStyleProperty(CSSPropertyWidth, 100, CSSPrimitiveValue::CSS_PERCENT AGE); 67
59 setInlineStyleProperty(CSSPropertyHeight, 100, CSSPrimitiveValue::CSS_PERCEN TAGE); 68 // FIXME: Need to force CSP to permit this element.
60 setInlineStyleProperty(CSSPropertyOverflow, CSSValueHidden); 69 RefPtrWillBeRawPtr<HTMLStyleElement> styleElement = HTMLStyleElement::create (document(), false);
61 setInlineStyleProperty(CSSPropertyDisplay, CSSValueFlex); 70 styleElement->setTextContent(String(pluginPlaceholderCss, sizeof(pluginPlace holderCss)));
62 setInlineStyleProperty(CSSPropertyAlignItems, CSSValueCenter); 71 appendChild(styleElement.release(), exceptionState);
63 setInlineStyleProperty(CSSPropertyBackgroundColor, CSSValueGray); 72 if (exceptionState.hadException())
64 setInlineStyleProperty(CSSPropertyFont, "12px -webkit-control"); 73 return false;
65 74
66 DEFINE_STATIC_LOCAL(AtomicString, contentId, ("plugin-placeholder-content")) ; 75 DEFINE_STATIC_LOCAL(AtomicString, contentId, ("plugin-placeholder-content")) ;
67 RefPtrWillBeRawPtr<HTMLDivElement> contentElement = HTMLDivElement::create(d ocument()); 76 RefPtrWillBeRawPtr<HTMLDivElement> contentElement = HTMLDivElement::create(d ocument());
68 contentElement->setIdAttribute(contentId); 77 contentElement->setIdAttribute(contentId);
69 contentElement->setInlineStyleProperty(CSSPropertyTextAlign, CSSValueCenter) ;
70 contentElement->setInlineStyleProperty(CSSPropertyMargin, CSSValueAuto);
71 78
72 DEFINE_STATIC_LOCAL(AtomicString, messageId, ("plugin-placeholder-message")) ; 79 DEFINE_STATIC_LOCAL(AtomicString, messageId, ("plugin-placeholder-message")) ;
73 RefPtrWillBeRawPtr<HTMLDivElement> messageElement = HTMLDivElement::create(d ocument()); 80 RefPtrWillBeRawPtr<HTMLDivElement> messageElement = HTMLDivElement::create(d ocument());
74 messageElement->setIdAttribute(messageId); 81 messageElement->setIdAttribute(messageId);
75 m_messageElement = messageElement.get(); 82 m_messageElement = messageElement.get();
76 contentElement->appendChild(messageElement.release(), exceptionState); 83 contentElement->appendChild(messageElement.release(), exceptionState);
77 if (exceptionState.hadException()) 84 if (exceptionState.hadException())
78 return false; 85 return false;
79 86
80 appendChild(contentElement.release(), exceptionState); 87 appendChild(contentElement.release(), exceptionState);
81 if (exceptionState.hadException()) 88 if (exceptionState.hadException())
82 return false; 89 return false;
83 90
84 return true; 91 return true;
85 } 92 }
86 93
87 } // namespace blink 94 } // namespace blink
OLDNEW
« Source/core/css/pluginPlaceholder.css ('K') | « Source/core/css/pluginPlaceholder.css ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698