Skip to content

Commit

Permalink
Keep track of plug-in snapshots clicked by user
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=103206
<rdar://problem/12746483>

Reviewed by Anders Carlsson.

Source/WebCore:

* html/HTMLPlugInImageElement.cpp:
(WebCore::HTMLPlugInImageElement::HTMLPlugInImageElement): Initially the hash is
unknown. Set to 0. Move the check for whether to snapshot the plugin into the
new function subframeLoaderWillLoadPlugIn.
(WebCore::HTMLPlugInImageElement::userDidClickSnapshot): Rename
setPendingClickEvent to userDidClickSnapshot. In addition to holding onto the
click event used to activate the plug-in, the function now also tells the plug-in
client to add the origin hash as an auto-start origin.
(WebCore::HTMLPlugInImageElement::subframeLoaderWillLoadPlugIn): Calculate the
hash based on the provided URL, which is the URL the plug-in will load. Extend
the check that used to be in the constructor to see if the plug-in should not
automatically load, including checking the plug-in size and whether the hash
is an auto-start origin.
* html/HTMLPlugInImageElement.h: Rename setPendingClickEvent to userDidClickSnapshot
and add a variable for the origin hash.

* loader/SubframeLoader.cpp:
(WebCore::SubframeLoader::requestPlugin): When the loader is about to load the
plug-in, pass the URL to the element, so that it can calculate the hash.

* page/Page.cpp:
(WebCore::Page::Page): Take the plugInClient from the page clients.
(WebCore::Page::~Page): If the client exists, tell it that the page is being
destroyed.
(WebCore::Page::PageClients::PageClients): Initialize this optional client to
null.
* page/Page.h: Add PlugInClient to page clients.
(PageClients): Add PlugInClient variable.
(WebCore::Page::plugInClient):
* page/PlugInClient.h: Added.

* rendering/RenderSnapshottedPlugIn.cpp:
(WebCore::RenderSnapshottedPlugIn::handleEvent): Call the renamed function
userDidClickSnapshot().
(WebCore::RenderSnapshottedPlugIn::layout): Move the check of the plug-in size
to subframeLoaderWillLoadPlugIn.

Add PlugInClient.h.
* GNUmakefile.list.am:
* Target.pri:
* WebCore.vcproj/WebCore.vcproj:
* WebCore.xcodeproj/project.pbxproj:

Source/WebKit2:

Create a new provider class for the web context that maintains a mapping of the plug-in origins
allowed to auto-start for a specific page origin.

* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::WebPage): Create and set WebPlugInClient.

Implement WebCore::PlugInClient.
* WebProcess/WebCoreSupport/WebPlugInClient.cpp: Added.
(WebKit::WebPlugInClient::WebPlugInClient):
(WebKit::WebPlugInClient::~WebPlugInClient):
(WebKit::WebPlugInClient::pageDestroyed):
(WebKit::WebPlugInClient::isAutoStartOrigin): Forward to WebProcess.
(WebKit::WebPlugInClient::addAutoStartOrigin): Forward to WebProcess.
* WebProcess/WebCoreSupport/WebPlugInClient.h: Added.

* WebProcess/WebProcess.cpp: Maintains a copy of the hash set.
(WebKit::WebProcess::isPlugInAutoStartOrigin): Look for the hash in the set.
(WebKit::WebProcess::addPlugInAutoStartOrigin): Tell the UI process to add the hash for the page.
(WebKit::WebProcess::didAddPlugInAutoStartOrigin): Add the hash to the cached set.
* WebProcess/WebProcess.h:
* WebProcess/WebProcess.messages.in: Add DidAddPlugInAutoStartOrigin.

Add the auto-start provider.
* UIProcess/WebContext.cpp:
(WebKit::WebContext::WebContext): Initialize the provider.
(WebKit::WebContext::addPlugInAutoStartOriginHash): Forward to the provider.
* UIProcess/WebContext.h:
* UIProcess/WebContext.messages.in: Add AddPlugInAutoStartOriginHash.

The provider class maintains a map of page domains to hashes, and a set of all the hashes.
The latter will be used to initialize new web processes without having to crawl through the
whole map.
* UIProcess/Plugins/PlugInAutoStartProvider.cpp: Added.
(WebKit::PlugInAutoStartProvider::PlugInAutoStartProvider):
(WebKit::PlugInAutoStartProvider::addAutoStartOrigin): Add the origin to the map and set. Tell
all processes to add the origin to their local copies.
* UIProcess/Plugins/PlugInAutoStartProvider.h: Added.

Add PlugInAutoStartProvider and WebPlugInClient.
* CMakeLists.txt:
* GNUmakefile.list.am:
* Target.pri:
* WebKit2.xcodeproj/project.pbxproj:
* win/WebKit2.vcproj:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@137230 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
qanat committed Dec 11, 2012
1 parent ef8926f commit f52c5da
Show file tree
Hide file tree
Showing 30 changed files with 531 additions and 24 deletions.
51 changes: 51 additions & 0 deletions Source/WebCore/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,54 @@
2012-12-10 Jon Lee <jonlee@apple.com>

Keep track of plug-in snapshots clicked by user
https://bugs.webkit.org/show_bug.cgi?id=103206
<rdar://problem/12746483>

Reviewed by Anders Carlsson.

* html/HTMLPlugInImageElement.cpp:
(WebCore::HTMLPlugInImageElement::HTMLPlugInImageElement): Initially the hash is
unknown. Set to 0. Move the check for whether to snapshot the plugin into the
new function subframeLoaderWillLoadPlugIn.
(WebCore::HTMLPlugInImageElement::userDidClickSnapshot): Rename
setPendingClickEvent to userDidClickSnapshot. In addition to holding onto the
click event used to activate the plug-in, the function now also tells the plug-in
client to add the origin hash as an auto-start origin.
(WebCore::HTMLPlugInImageElement::subframeLoaderWillLoadPlugIn): Calculate the
hash based on the provided URL, which is the URL the plug-in will load. Extend
the check that used to be in the constructor to see if the plug-in should not
automatically load, including checking the plug-in size and whether the hash
is an auto-start origin.
* html/HTMLPlugInImageElement.h: Rename setPendingClickEvent to userDidClickSnapshot
and add a variable for the origin hash.

* loader/SubframeLoader.cpp:
(WebCore::SubframeLoader::requestPlugin): When the loader is about to load the
plug-in, pass the URL to the element, so that it can calculate the hash.

* page/Page.cpp:
(WebCore::Page::Page): Take the plugInClient from the page clients.
(WebCore::Page::~Page): If the client exists, tell it that the page is being
destroyed.
(WebCore::Page::PageClients::PageClients): Initialize this optional client to
null.
* page/Page.h: Add PlugInClient to page clients.
(PageClients): Add PlugInClient variable.
(WebCore::Page::plugInClient):
* page/PlugInClient.h: Added.

* rendering/RenderSnapshottedPlugIn.cpp:
(WebCore::RenderSnapshottedPlugIn::handleEvent): Call the renamed function
userDidClickSnapshot().
(WebCore::RenderSnapshottedPlugIn::layout): Move the check of the plug-in size
to subframeLoaderWillLoadPlugIn.

Add PlugInClient.h.
* GNUmakefile.list.am:
* Target.pri:
* WebCore.vcproj/WebCore.vcproj:
* WebCore.xcodeproj/project.pbxproj:

2012-12-10 Antti Koivisto <antti@apple.com>

Not reviewed.
Expand Down
1 change: 1 addition & 0 deletions Source/WebCore/GNUmakefile.list.am
Original file line number Diff line number Diff line change
Expand Up @@ -4110,6 +4110,7 @@ webcore_sources += \
Source/WebCore/page/PerformanceTiming.h \
Source/WebCore/page/PerformanceUserTiming.cpp \
Source/WebCore/page/PerformanceUserTiming.h \
Source/WebCore/page/PlugInClient.h \
Source/WebCore/page/PointerLockController.cpp \
Source/WebCore/page/PointerLockController.h \
Source/WebCore/page/PopupOpeningObserver.h \
Expand Down
1 change: 1 addition & 0 deletions Source/WebCore/Target.pri
Original file line number Diff line number Diff line change
Expand Up @@ -2057,6 +2057,7 @@ HEADERS += \
page/PageGroupLoadDeferrer.h \
page/Page.h \
page/PageVisibilityState.h \
page/PlugInClient.h \
page/PopupOpeningObserver.h \
page/PrintContext.h \
page/Screen.h \
Expand Down
4 changes: 4 additions & 0 deletions Source/WebCore/WebCore.vcproj/WebCore.vcproj
Original file line number Diff line number Diff line change
Expand Up @@ -27293,6 +27293,10 @@
RelativePath="..\page\PerformanceTiming.h"
>
</File>
<File
RelativePath="..\page\PlugInClient.h"
>
</File>
<File
RelativePath="..\page\PoppupOpeningObserver.h"
>
Expand Down
4 changes: 4 additions & 0 deletions Source/WebCore/WebCore.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -950,6 +950,7 @@
31C0FF4C0E4CEFDD007D6FE5 /* DOMWebKitTransitionEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = 31C0FF460E4CEFDD007D6FE5 /* DOMWebKitTransitionEvent.h */; };
31C0FF4D0E4CEFDD007D6FE5 /* DOMWebKitTransitionEvent.mm in Sources */ = {isa = PBXBuildFile; fileRef = 31C0FF470E4CEFDD007D6FE5 /* DOMWebKitTransitionEvent.mm */; };
31C0FF4E0E4CEFDD007D6FE5 /* DOMWebKitTransitionEventInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 31C0FF480E4CEFDD007D6FE5 /* DOMWebKitTransitionEventInternal.h */; };
31D591B316697A6C00E6BF02 /* PlugInClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 31D591B116697A6C00E6BF02 /* PlugInClient.h */; settings = {ATTRIBUTES = (Private, ); }; };
31D591BB166C2E6C00E6BF02 /* PlugInOriginHash.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 31D591B9166C2E6C00E6BF02 /* PlugInOriginHash.cpp */; };
31D591BC166C2E6C00E6BF02 /* PlugInOriginHash.h in Headers */ = {isa = PBXBuildFile; fileRef = 31D591BA166C2E6C00E6BF02 /* PlugInOriginHash.h */; settings = {ATTRIBUTES = (); }; };
31EC1E2814FF60EE00C94662 /* JSNotificationPermissionCallback.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 31EC1E2614FF60EE00C94662 /* JSNotificationPermissionCallback.cpp */; };
Expand Down Expand Up @@ -8154,6 +8155,7 @@
31C0FF460E4CEFDD007D6FE5 /* DOMWebKitTransitionEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DOMWebKitTransitionEvent.h; sourceTree = "<group>"; };
31C0FF470E4CEFDD007D6FE5 /* DOMWebKitTransitionEvent.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DOMWebKitTransitionEvent.mm; sourceTree = "<group>"; };
31C0FF480E4CEFDD007D6FE5 /* DOMWebKitTransitionEventInternal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DOMWebKitTransitionEventInternal.h; sourceTree = "<group>"; };
31D591B116697A6C00E6BF02 /* PlugInClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PlugInClient.h; sourceTree = "<group>"; };
31D591B9166C2E6C00E6BF02 /* PlugInOriginHash.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PlugInOriginHash.cpp; sourceTree = "<group>"; };
31D591BA166C2E6C00E6BF02 /* PlugInOriginHash.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PlugInOriginHash.h; sourceTree = "<group>"; };
31E8D8BA160BC94B004CE8F5 /* RenderSnapshottedPlugIn.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderSnapshottedPlugIn.cpp; sourceTree = "<group>"; };
Expand Down Expand Up @@ -16081,6 +16083,7 @@
8AF4E55811DC5A63000ED3DE /* PerformanceTiming.cpp */,
8AF4E55911DC5A63000ED3DE /* PerformanceTiming.h */,
8AF4E55A11DC5A63000ED3DE /* PerformanceTiming.idl */,
31D591B116697A6C00E6BF02 /* PlugInClient.h */,
3772B09516535856000A49CA /* PopupOpeningObserver.h */,
B776D43C1104527500BEB0EC /* PrintContext.cpp */,
B776D43A1104525D00BEB0EC /* PrintContext.h */,
Expand Down Expand Up @@ -25918,6 +25921,7 @@
DEBCCDD416646EAF00A452E1 /* MediaControlElementTypes.h in Headers */,
D66817FB166FE6D700FA07B4 /* HTMLTemplateElement.h in Headers */,
D6489D26166FFCF1007C031B /* JSHTMLTemplateElement.h in Headers */,
31D591B316697A6C00E6BF02 /* PlugInClient.h in Headers */,
31D591BC166C2E6C00E6BF02 /* PlugInOriginHash.h in Headers */,
986EA88315FFF29000985E5E /* PrerenderClient.h in Headers */,
);
Expand Down
55 changes: 49 additions & 6 deletions Source/WebCore/html/HTMLPlugInImageElement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,12 @@
#include "HTMLImageLoader.h"
#include "HTMLNames.h"
#include "Image.h"
#include "Logging.h"
#include "MouseEvent.h"
#include "NodeRenderStyle.h"
#include "Page.h"
#include "PlugInClient.h"
#include "PlugInOriginHash.h"
#include "RenderEmbeddedObject.h"
#include "RenderImage.h"
#include "RenderSnapshottedPlugIn.h"
Expand All @@ -39,6 +42,8 @@

namespace WebCore {

static const int autoStartPlugInSizeThresholdWidth = 1;
static const int autoStartPlugInSizeThresholdHeight = 1;
// This delay should not exceed the snapshot delay in PluginView.cpp
static const double simulatedMouseClickTimerDelay = .75;

Expand All @@ -54,11 +59,6 @@ HTMLPlugInImageElement::HTMLPlugInImageElement(const QualifiedName& tagName, Doc
, m_simulatedMouseClickTimer(this, &HTMLPlugInImageElement::simulatedMouseClickTimerFired, simulatedMouseClickTimerDelay)
{
setHasCustomCallbacks();

if (document->page()
&& document->page()->settings()->plugInSnapshottingEnabled()
&& !ScriptController::processingUserGesture())
setDisplayState(WaitingForSnapshot);
}

HTMLPlugInImageElement::~HTMLPlugInImageElement()
Expand Down Expand Up @@ -260,9 +260,11 @@ void HTMLPlugInImageElement::updateSnapshot(PassRefPtr<Image> image)
setDisplayState(DisplayingSnapshot);
}

void HTMLPlugInImageElement::setPendingClickEvent(PassRefPtr<MouseEvent> event)
void HTMLPlugInImageElement::userDidClickSnapshot(PassRefPtr<MouseEvent> event)
{
m_pendingClickEventFromSnapshot = event;
if (document()->page())
document()->page()->plugInClient()->addAutoStartOrigin(document()->page()->mainFrame()->document()->baseURL().host(), m_plugInOriginHash);
}

void HTMLPlugInImageElement::dispatchPendingMouseClick()
Expand All @@ -282,4 +284,45 @@ void HTMLPlugInImageElement::simulatedMouseClickTimerFired(DeferrableOneShotTime
m_pendingClickEventFromSnapshot = nullptr;
}

void HTMLPlugInImageElement::subframeLoaderWillLoadPlugIn(const KURL& url)
{
if (!document()->page()
|| !document()->page()->settings()->plugInSnapshottingEnabled())
return;

if (!renderer()->isSnapshottedPlugIn()) {
LOG(Plugins, "%p Renderer is not snapshotted plugin, set to play", this);
return;
}
if (ScriptController::processingUserGesture()) {
LOG(Plugins, "%p Script is processing user gesture, set to play", this);
return;
}

LayoutRect rect = toRenderSnapshottedPlugIn(renderer())->contentBoxRect();
int width = rect.width();
int height = rect.height();
if (!width || !height || (width <= autoStartPlugInSizeThresholdWidth && height <= autoStartPlugInSizeThresholdHeight)) {
LOG(Plugins, "%p Plugin is %dx%d, set to play", this, width, height);
return;
}

if (!document()->page() || !document()->page()->plugInClient()) {
setDisplayState(WaitingForSnapshot);
return;
}

LOG(Plugins, "%p Plugin URL: %s", this, m_url.utf8().data());
LOG(Plugins, " loaded URL: %s", url.string().utf8().data());

m_plugInOriginHash = PlugInOriginHash::hash(this, url);
if (m_plugInOriginHash && document()->page()->plugInClient()->isAutoStartOrigin(m_plugInOriginHash)) {
LOG(Plugins, "%p Plugin hash %x is auto-start, set to play", this, m_plugInOriginHash);
return;
}

LOG(Plugins, "%p Plugin hash %x is %dx%d, origin is not auto-start, set to wait for snapshot", this, m_plugInOriginHash, width, height);
setDisplayState(WaitingForSnapshot);
}

} // namespace WebCore
6 changes: 5 additions & 1 deletion Source/WebCore/html/HTMLPlugInImageElement.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,10 @@ class HTMLPlugInImageElement : public HTMLPlugInElement, public ImageLoaderClien
bool needsWidgetUpdate() const { return m_needsWidgetUpdate; }
void setNeedsWidgetUpdate(bool needsWidgetUpdate) { m_needsWidgetUpdate = needsWidgetUpdate; }

void setPendingClickEvent(PassRefPtr<MouseEvent>);
void userDidClickSnapshot(PassRefPtr<MouseEvent>);

// Plug-in URL might not be the same as url() with overriding parameters.
void subframeLoaderWillLoadPlugIn(const KURL& plugInURL);

protected:
HTMLPlugInImageElement(const QualifiedName& tagName, Document*, bool createdByParser, PreferPlugInsForImagesOption);
Expand Down Expand Up @@ -103,6 +106,7 @@ class HTMLPlugInImageElement : public HTMLPlugInElement, public ImageLoaderClien
RefPtr<RenderStyle> m_customStyleForPageCache;
RefPtr<MouseEvent> m_pendingClickEventFromSnapshot;
DeferrableOneShotTimer<HTMLPlugInImageElement> m_simulatedMouseClickTimer;
unsigned m_plugInOriginHash;
};

} // namespace WebCore
Expand Down
1 change: 1 addition & 0 deletions Source/WebCore/loader/SubframeLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ bool SubframeLoader::requestPlugin(HTMLPlugInImageElement* ownerElement, const K
return false;

ASSERT(ownerElement->hasTagName(objectTag) || ownerElement->hasTagName(embedTag));
ownerElement->subframeLoaderWillLoadPlugIn(url);
return loadPlugin(ownerElement, url, mimeType, paramNames, paramValues, useFallback);
}

Expand Down
5 changes: 5 additions & 0 deletions Source/WebCore/page/Page.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
#include "NetworkStateNotifier.h"
#include "PageCache.h"
#include "PageGroup.h"
#include "PlugInClient.h"
#include "PluginData.h"
#include "PluginView.h"
#include "PointerLockController.h"
Expand Down Expand Up @@ -133,6 +134,7 @@ Page::Page(PageClients& pageClients)
, m_backForwardController(BackForwardController::create(this, pageClients.backForwardClient))
, m_theme(RenderTheme::themeForPage(this))
, m_editorClient(pageClients.editorClient)
, m_plugInClient(pageClients.plugInClient)
, m_validationMessageClient(pageClients.validationMessageClient)
, m_subframeCount(0)
, m_openedByDOM(false)
Expand Down Expand Up @@ -198,6 +200,8 @@ Page::~Page()
}

m_editorClient->pageDestroyed();
if (m_plugInClient)
m_plugInClient->pageDestroyed();
if (m_alternativeTextClient)
m_alternativeTextClient->pageDestroyed();

Expand Down Expand Up @@ -1336,6 +1340,7 @@ Page::PageClients::PageClients()
, editorClient(0)
, dragClient(0)
, inspectorClient(0)
, plugInClient(0)
, validationMessageClient(0)
{
}
Expand Down
4 changes: 4 additions & 0 deletions Source/WebCore/page/Page.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ namespace WebCore {
class MediaCanStartListener;
class Node;
class PageGroup;
class PlugInClient;
class PluginData;
class PluginViewBase;
class PointerLockController;
Expand Down Expand Up @@ -127,6 +128,7 @@ namespace WebCore {
EditorClient* editorClient;
DragClient* dragClient;
InspectorClient* inspectorClient;
PlugInClient* plugInClient;
RefPtr<BackForwardList> backForwardClient;
ValidationMessageClient* validationMessageClient;
};
Expand All @@ -149,6 +151,7 @@ namespace WebCore {
bool canStartMedia() const { return m_canStartMedia; }

EditorClient* editorClient() const { return m_editorClient; }
PlugInClient* plugInClient() const { return m_plugInClient; }

void setMainFrame(PassRefPtr<Frame>);
Frame* mainFrame() const { return m_mainFrame.get(); }
Expand Down Expand Up @@ -406,6 +409,7 @@ namespace WebCore {
RefPtr<RenderTheme> m_theme;

EditorClient* m_editorClient;
PlugInClient* m_plugInClient;
ValidationMessageClient* m_validationMessageClient;

FeatureObserver m_featureObserver;
Expand Down
44 changes: 44 additions & 0 deletions Source/WebCore/page/PlugInClient.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* Copyright (C) 2012 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/

#ifndef PlugInClient_h
#define PlugInClient_h

#include <wtf/Forward.h>

namespace WebCore {

class PlugInClient {
public:
virtual void pageDestroyed() = 0;
virtual bool isAutoStartOrigin(unsigned plugInOriginHash) = 0;
virtual void addAutoStartOrigin(const String& pageOrigin, unsigned plugInOriginHash) = 0;

protected:
virtual ~PlugInClient() { }
};

}
#endif // PlugInClient_h
14 changes: 1 addition & 13 deletions Source/WebCore/rendering/RenderSnapshottedPlugIn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ void RenderSnapshottedPlugIn::handleEvent(Event* event)
return;

plugInImageElement()->setDisplayState(HTMLPlugInElement::PlayingWithPendingMouseClick);
plugInImageElement()->setPendingClickEvent(mouseEvent);
plugInImageElement()->userDidClickSnapshot(mouseEvent);

if (widget()) {
if (Frame* frame = document()->frame())
Expand Down Expand Up @@ -249,16 +249,4 @@ LayoutRect RenderSnapshottedPlugIn::tryToFitStartLabel(LabelSize size, const Lay
return candidateRect;
}

void RenderSnapshottedPlugIn::layout()
{
RenderEmbeddedObject::layout();
if (plugInImageElement()->displayState() < HTMLPlugInElement::Playing) {
LayoutRect rect = contentBoxRect();
int width = rect.width();
int height = rect.height();
if (!width || !height || (width <= autoStartPlugInSizeThresholdWidth && height <= autoStartPlugInSizeThresholdHeight))
plugInImageElement()->setDisplayState(HTMLPlugInElement::Playing);
}
}

} // namespace WebCore
2 changes: 0 additions & 2 deletions Source/WebCore/rendering/RenderSnapshottedPlugIn.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,6 @@ class RenderSnapshottedPlugIn : public RenderEmbeddedObject {
LayoutRect tryToFitStartLabel(LabelSize, const LayoutRect& contentBox) const;
Image* startLabelImage(LabelSize) const;

virtual void layout() OVERRIDE;

OwnPtr<RenderImageResource> m_snapshotResource;
bool m_shouldShowLabel;
DeferrableOneShotTimer<RenderSnapshottedPlugIn> m_hoverDelayTimer;
Expand Down
2 changes: 2 additions & 0 deletions Source/WebKit2/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,7 @@ set(WebKit2_SOURCES
UIProcess/Notifications/WebNotificationManagerProxy.cpp
UIProcess/Notifications/WebNotificationProvider.cpp

UIProcess/Plugins/PlugInAutoStartProvider.cpp
UIProcess/Plugins/PluginInfoStore.cpp
UIProcess/Plugins/PluginProcessManager.cpp
UIProcess/Plugins/PluginProcessProxy.cpp
Expand Down Expand Up @@ -473,6 +474,7 @@ set(WebKit2_SOURCES
WebProcess/WebCoreSupport/WebNetworkInfoClient.cpp
WebProcess/WebCoreSupport/WebNotificationClient.cpp
WebProcess/WebCoreSupport/WebPlatformStrategies.cpp
WebProcess/WebCoreSupport/WebPlugInClient.cpp
WebProcess/WebCoreSupport/WebPopupMenu.cpp
WebProcess/WebCoreSupport/WebSearchPopupMenu.cpp
WebProcess/WebCoreSupport/WebVibrationClient.cpp
Expand Down
Loading

0 comments on commit f52c5da

Please sign in to comment.