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
3 // found in the LICENSE file.
5 #ifndef DictionaryPluginPlaceholder_h
6 #define DictionaryPluginPlaceholder_h
8 #include "bindings/core/v8/Dictionary.h"
9 #include "core/html/shadow/PluginPlaceholderElement.h"
10 #include "core/plugins/PluginPlaceholder.h"
11 #include "wtf/text/WTFString.h"
15 // Manipulates a plugin placeholder element based on a fixed dictionary given.
16 // Used for layout tests that examine the formatting of structured placeholders.
17 class DictionaryPluginPlaceholder : public NoBaseWillBeGarbageCollected<DictionaryPluginPlaceholder>, public PluginPlaceholder {
18 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(DictionaryPluginPlaceholder);
20 static PassOwnPtrWillBeRawPtr<DictionaryPluginPlaceholder> create(Document& document, const Dictionary& options)
22 RefPtrWillBeRawPtr<PluginPlaceholderElement> placeholder = PluginPlaceholderElement::create(document);
24 if (DictionaryHelper::get(options, "message", stringValue))
25 placeholder->setMessage(stringValue);
28 if (DictionaryHelper::get(options, "closeable", booleanValue))
29 placeholder->setIsCloseable(booleanValue);
31 return adoptPtrWillBeNoop(new DictionaryPluginPlaceholder(placeholder.release()));
35 virtual ~DictionaryPluginPlaceholder() override { }
37 virtual void trace(Visitor* visitor) { visitor->trace(m_pluginPlaceholderElement); }
39 virtual void loadIntoContainer(ContainerNode& container) override
41 container.removeChildren();
42 container.appendChild(m_pluginPlaceholderElement, ASSERT_NO_EXCEPTION);
46 DictionaryPluginPlaceholder(PassRefPtrWillBeRawPtr<PluginPlaceholderElement> element) : m_pluginPlaceholderElement(element) { }
48 RefPtrWillBeMember<PluginPlaceholderElement> m_pluginPlaceholderElement;
53 #endif // DictionaryPluginPlaceholder_h