1/*
2 * Copyright (C) 2010 Apple Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 *
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
15 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
16 * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
17 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
18 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
19 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
20 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
22 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23 */
24
25#pragma once
26
27#include "AudioHardwareListener.h"
28#include "BridgeJSC.h"
29#include "PlatformLayer.h"
30#include "ScrollTypes.h"
31#include "Widget.h"
32#include <wtf/text/WTFString.h>
33
34#if PLATFORM(COCOA)
35typedef struct objc_object* id;
36#endif
37
38namespace JSC {
39 class ExecState;
40 class JSGlobalObject;
41 class JSObject;
42}
43
44namespace WebCore {
45
46class Scrollbar;
47
48// PluginViewBase is a widget that all plug-in views inherit from, both in Webkit and WebKit2.
49// It's intended as a stopgap measure until we can merge all plug-in views into a single plug-in view.
50class PluginViewBase : public Widget {
51public:
52 virtual PlatformLayer* platformLayer() const { return 0; }
53#if PLATFORM(IOS_FAMILY)
54 virtual bool willProvidePluginLayer() const { return false; }
55 virtual void attachPluginLayer() { }
56 virtual void detachPluginLayer() { }
57#endif
58
59 virtual JSC::JSObject* scriptObject(JSC::JSGlobalObject*) { return 0; }
60 virtual void storageBlockingStateChanged() { }
61 virtual void privateBrowsingStateChanged(bool) { }
62 virtual bool getFormValue(String&) { return false; }
63 virtual bool scroll(ScrollDirection, ScrollGranularity) { return false; }
64
65 // A plug-in can ask WebKit to handle scrollbars for it.
66 virtual Scrollbar* horizontalScrollbar() { return 0; }
67 virtual Scrollbar* verticalScrollbar() { return 0; }
68
69 // FIXME: This is a hack that works around the fact that the WebKit2 PluginView isn't a ScrollableArea.
70 virtual bool wantsWheelEvents() { return false; }
71 virtual bool supportsKeyboardFocus() const { return false; }
72 virtual bool canProcessDrag() const { return false; }
73
74 virtual bool shouldAlwaysAutoStart() const { return false; }
75 virtual void beginSnapshottingRunningPlugin() { }
76
77 virtual bool shouldAllowNavigationFromDrags() const { return false; }
78
79 bool isPluginViewBase() const override { return true; }
80 virtual bool shouldNotAddLayer() const { return false; }
81
82 virtual AudioHardwareActivityType audioHardwareActivity() const { return AudioHardwareActivityType::Unknown; }
83
84 virtual void setJavaScriptPaused(bool) { }
85
86 virtual RefPtr<JSC::Bindings::Instance> bindingInstance() { return nullptr; }
87
88 virtual void willDetachRenderer() { }
89
90#if PLATFORM(COCOA)
91 virtual id accessibilityAssociatedPluginParentForElement(Element*) const { return nullptr; }
92#endif
93
94protected:
95 explicit PluginViewBase(PlatformWidget widget = 0) : Widget(widget) { }
96};
97
98} // namespace WebCore
99
100SPECIALIZE_TYPE_TRAITS_WIDGET(PluginViewBase, isPluginViewBase())
101