OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2008, 2009, 2011, 2012 Apple Inc. All rights reserved. | 2 * Copyright (C) 2008, 2009, 2011, 2012 Apple Inc. All rights reserved. |
3 * | 3 * |
4 * This library is free software; you can redistribute it and/or | 4 * This library is free software; you can redistribute it and/or |
5 * modify it under the terms of the GNU Library General Public | 5 * modify it under the terms of the GNU Library General Public |
6 * License as published by the Free Software Foundation; either | 6 * License as published by the Free Software Foundation; either |
7 * version 2 of the License, or (at your option) any later version. | 7 * version 2 of the License, or (at your option) any later version. |
8 * | 8 * |
9 * This library is distributed in the hope that it will be useful, | 9 * This library is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 22 matching lines...) Expand all Loading... |
33 class FrameLoader; | 33 class FrameLoader; |
34 class Image; | 34 class Image; |
35 class MouseEvent; | 35 class MouseEvent; |
36 class Widget; | 36 class Widget; |
37 | 37 |
38 enum PluginCreationOption { | 38 enum PluginCreationOption { |
39 CreateAnyWidgetType, | 39 CreateAnyWidgetType, |
40 CreateOnlyNonNetscapePlugins, | 40 CreateOnlyNonNetscapePlugins, |
41 }; | 41 }; |
42 | 42 |
43 enum PreferPlugInsForImagesOption { | |
44 ShouldPreferPlugInsForImages, | |
45 ShouldNotPreferPlugInsForImages | |
46 }; | |
47 | |
48 // Base class for HTMLObjectElement and HTMLEmbedElement | 43 // Base class for HTMLObjectElement and HTMLEmbedElement |
49 class HTMLPlugInImageElement : public HTMLPlugInElement { | 44 class HTMLPlugInImageElement : public HTMLPlugInElement { |
50 public: | 45 public: |
51 virtual ~HTMLPlugInImageElement(); | 46 virtual ~HTMLPlugInImageElement(); |
52 | 47 |
53 RenderEmbeddedObject* renderEmbeddedObject() const; | 48 RenderEmbeddedObject* renderEmbeddedObject() const; |
54 | 49 |
55 virtual void setDisplayState(DisplayState) OVERRIDE; | 50 virtual void setDisplayState(DisplayState) OVERRIDE; |
56 | 51 |
57 virtual void updateWidget(PluginCreationOption) = 0; | 52 virtual void updateWidget(PluginCreationOption) = 0; |
58 | 53 |
59 const String& serviceType() const { return m_serviceType; } | 54 const String& serviceType() const { return m_serviceType; } |
60 const String& url() const { return m_url; } | 55 const String& url() const { return m_url; } |
61 const KURL& loadedUrl() const { return m_loadedUrl; } | 56 const KURL& loadedUrl() const { return m_loadedUrl; } |
62 | 57 |
63 const String loadedMimeType() const | 58 const String loadedMimeType() const |
64 { | 59 { |
65 String mimeType = serviceType(); | 60 String mimeType = serviceType(); |
66 if (mimeType.isEmpty()) | 61 if (mimeType.isEmpty()) |
67 mimeType = mimeTypeFromURL(m_loadedUrl); | 62 mimeType = mimeTypeFromURL(m_loadedUrl); |
68 return mimeType; | 63 return mimeType; |
69 } | 64 } |
70 | 65 |
71 bool shouldPreferPlugInsForImages() const { return m_shouldPreferPlugInsForI
mages; } | |
72 | |
73 // Public for FrameView::addWidgetToUpdate() | 66 // Public for FrameView::addWidgetToUpdate() |
74 bool needsWidgetUpdate() const { return m_needsWidgetUpdate; } | 67 bool needsWidgetUpdate() const { return m_needsWidgetUpdate; } |
75 void setNeedsWidgetUpdate(bool needsWidgetUpdate) { m_needsWidgetUpdate = ne
edsWidgetUpdate; } | 68 void setNeedsWidgetUpdate(bool needsWidgetUpdate) { m_needsWidgetUpdate = ne
edsWidgetUpdate; } |
76 | 69 |
77 protected: | 70 protected: |
78 HTMLPlugInImageElement(const QualifiedName& tagName, Document&, bool created
ByParser, PreferPlugInsForImagesOption); | 71 HTMLPlugInImageElement(const QualifiedName& tagName, Document&, bool created
ByParser, PreferPlugInsForImagesOption); |
79 | 72 |
80 bool isImageType(); | |
81 | |
82 OwnPtr<HTMLImageLoader> m_imageLoader; | 73 OwnPtr<HTMLImageLoader> m_imageLoader; |
83 String m_serviceType; | |
84 String m_url; | |
85 KURL m_loadedUrl; | 74 KURL m_loadedUrl; |
86 | 75 |
87 static void updateWidgetCallback(Node*); | 76 static void updateWidgetCallback(Node*); |
88 virtual void attach(const AttachContext& = AttachContext()) OVERRIDE; | 77 virtual void attach(const AttachContext& = AttachContext()) OVERRIDE; |
89 virtual void detach(const AttachContext& = AttachContext()) OVERRIDE; | 78 virtual void detach(const AttachContext& = AttachContext()) OVERRIDE; |
90 | 79 |
91 bool allowedToLoadFrameURL(const String& url); | 80 bool allowedToLoadFrameURL(const String& url); |
92 bool wouldLoadAsNetscapePlugin(const String& url, const String& serviceType)
; | 81 bool wouldLoadAsNetscapePlugin(const String& url, const String& serviceType)
; |
93 | 82 |
94 virtual void didMoveToNewDocument(Document& oldDocument) OVERRIDE; | 83 virtual void didMoveToNewDocument(Document& oldDocument) OVERRIDE; |
(...skipping 12 matching lines...) Expand all Loading... |
107 void swapRendererTimerFired(Timer<HTMLPlugInImageElement>*); | 96 void swapRendererTimerFired(Timer<HTMLPlugInImageElement>*); |
108 | 97 |
109 void restartSimilarPlugIns(); | 98 void restartSimilarPlugIns(); |
110 | 99 |
111 bool loadPlugin(const KURL&, const String& mimeType, const Vector<String>& p
aramNames, const Vector<String>& paramValues, bool useFallback); | 100 bool loadPlugin(const KURL&, const String& mimeType, const Vector<String>& p
aramNames, const Vector<String>& paramValues, bool useFallback); |
112 bool pluginIsLoadable(const KURL&, const String& mimeType); | 101 bool pluginIsLoadable(const KURL&, const String& mimeType); |
113 | 102 |
114 virtual bool isPlugInImageElement() const OVERRIDE { return true; } | 103 virtual bool isPlugInImageElement() const OVERRIDE { return true; } |
115 | 104 |
116 bool m_needsWidgetUpdate; | 105 bool m_needsWidgetUpdate; |
117 bool m_shouldPreferPlugInsForImages; | |
118 bool m_createdDuringUserGesture; | 106 bool m_createdDuringUserGesture; |
119 }; | 107 }; |
120 | 108 |
121 inline HTMLPlugInImageElement* toHTMLPlugInImageElement(Node* node) | 109 inline HTMLPlugInImageElement* toHTMLPlugInImageElement(Node* node) |
122 { | 110 { |
123 ASSERT_WITH_SECURITY_IMPLICATION(!node || node->isPluginElement()); | 111 ASSERT_WITH_SECURITY_IMPLICATION(!node || node->isPluginElement()); |
124 HTMLPlugInElement* plugInElement = static_cast<HTMLPlugInElement*>(node); | 112 HTMLPlugInElement* plugInElement = static_cast<HTMLPlugInElement*>(node); |
125 ASSERT_WITH_SECURITY_IMPLICATION(plugInElement->isPlugInImageElement()); | 113 ASSERT_WITH_SECURITY_IMPLICATION(plugInElement->isPlugInImageElement()); |
126 return static_cast<HTMLPlugInImageElement*>(plugInElement); | 114 return static_cast<HTMLPlugInImageElement*>(plugInElement); |
127 } | 115 } |
128 | 116 |
129 inline const HTMLPlugInImageElement* toHTMLPlugInImageElement(const Node* node) | 117 inline const HTMLPlugInImageElement* toHTMLPlugInImageElement(const Node* node) |
130 { | 118 { |
131 ASSERT_WITH_SECURITY_IMPLICATION(!node || node->isPluginElement()); | 119 ASSERT_WITH_SECURITY_IMPLICATION(!node || node->isPluginElement()); |
132 const HTMLPlugInElement* plugInElement = static_cast<const HTMLPlugInElement
*>(node); | 120 const HTMLPlugInElement* plugInElement = static_cast<const HTMLPlugInElement
*>(node); |
133 ASSERT_WITH_SECURITY_IMPLICATION(plugInElement->isPlugInImageElement()); | 121 ASSERT_WITH_SECURITY_IMPLICATION(plugInElement->isPlugInImageElement()); |
134 return static_cast<const HTMLPlugInImageElement*>(plugInElement); | 122 return static_cast<const HTMLPlugInImageElement*>(plugInElement); |
135 } | 123 } |
136 | 124 |
137 // This will catch anyone doing an unnecessary cast. | 125 // This will catch anyone doing an unnecessary cast. |
138 void toHTMLPlugInImageElement(const HTMLPlugInImageElement*); | 126 void toHTMLPlugInImageElement(const HTMLPlugInImageElement*); |
139 | 127 |
140 } // namespace WebCore | 128 } // namespace WebCore |
141 | 129 |
142 #endif // HTMLPlugInImageElement_h | 130 #endif // HTMLPlugInImageElement_h |
OLD | NEW |