Upstream version 11.40.271.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / core / plugins / testing / DictionaryPluginPlaceholder.h
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.
4
5 #ifndef DictionaryPluginPlaceholder_h
6 #define DictionaryPluginPlaceholder_h
7
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"
12
13 namespace blink {
14
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);
19 public:
20     static PassOwnPtrWillBeRawPtr<DictionaryPluginPlaceholder> create(Document& document, const Dictionary& options)
21     {
22         RefPtrWillBeRawPtr<PluginPlaceholderElement> placeholder = PluginPlaceholderElement::create(document);
23         String stringValue;
24         if (DictionaryHelper::get(options, "message", stringValue))
25             placeholder->setMessage(stringValue);
26
27         bool booleanValue;
28         if (DictionaryHelper::get(options, "closeable", booleanValue))
29             placeholder->setIsCloseable(booleanValue);
30
31         return adoptPtrWillBeNoop(new DictionaryPluginPlaceholder(placeholder.release()));
32     }
33
34 #if !ENABLE(OILPAN)
35     virtual ~DictionaryPluginPlaceholder() override { }
36 #endif
37     virtual void trace(Visitor* visitor) { visitor->trace(m_pluginPlaceholderElement); }
38
39     virtual void loadIntoContainer(ContainerNode& container) override
40     {
41         container.removeChildren();
42         container.appendChild(m_pluginPlaceholderElement, ASSERT_NO_EXCEPTION);
43     }
44
45 private:
46     DictionaryPluginPlaceholder(PassRefPtrWillBeRawPtr<PluginPlaceholderElement> element) : m_pluginPlaceholderElement(element) { }
47
48     RefPtrWillBeMember<PluginPlaceholderElement> m_pluginPlaceholderElement;
49 };
50
51 } // namespace blink
52
53 #endif // DictionaryPluginPlaceholder_h