Keep track of plug-in snapshots clicked by user
authorjonlee@apple.com <jonlee@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 11 Dec 2012 01:33:15 +0000 (01:33 +0000)
committerjonlee@apple.com <jonlee@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 11 Dec 2012 01:33:15 +0000 (01:33 +0000)
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: https://svn.webkit.org/repository/webkit/trunk@137230 268f45cc-cd09-0410-ab3c-d52691b4dbfc

30 files changed:
Source/WebCore/ChangeLog
Source/WebCore/GNUmakefile.list.am
Source/WebCore/Target.pri
Source/WebCore/WebCore.vcproj/WebCore.vcproj
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/html/HTMLPlugInImageElement.cpp
Source/WebCore/html/HTMLPlugInImageElement.h
Source/WebCore/loader/SubframeLoader.cpp
Source/WebCore/page/Page.cpp
Source/WebCore/page/Page.h
Source/WebCore/page/PlugInClient.h [new file with mode: 0644]
Source/WebCore/rendering/RenderSnapshottedPlugIn.cpp
Source/WebCore/rendering/RenderSnapshottedPlugIn.h
Source/WebKit2/CMakeLists.txt
Source/WebKit2/ChangeLog
Source/WebKit2/GNUmakefile.list.am
Source/WebKit2/Target.pri
Source/WebKit2/UIProcess/Plugins/PlugInAutoStartProvider.cpp [new file with mode: 0644]
Source/WebKit2/UIProcess/Plugins/PlugInAutoStartProvider.h [new file with mode: 0644]
Source/WebKit2/UIProcess/WebContext.cpp
Source/WebKit2/UIProcess/WebContext.h
Source/WebKit2/UIProcess/WebContext.messages.in
Source/WebKit2/WebKit2.xcodeproj/project.pbxproj
Source/WebKit2/WebProcess/WebCoreSupport/WebPlugInClient.cpp [new file with mode: 0644]
Source/WebKit2/WebProcess/WebCoreSupport/WebPlugInClient.h [new file with mode: 0644]
Source/WebKit2/WebProcess/WebPage/WebPage.cpp
Source/WebKit2/WebProcess/WebProcess.cpp
Source/WebKit2/WebProcess/WebProcess.h
Source/WebKit2/WebProcess/WebProcess.messages.in
Source/WebKit2/win/WebKit2.vcproj

index 7ab0819..451b2d2 100644 (file)
@@ -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.
index 8d44a25..5f5caa1 100644 (file)
@@ -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 \
index 9e39a9d..b03bb12 100644 (file)
@@ -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 \
index 45ded89..64da6dc 100755 (executable)
                                >
                        </File>
                        <File
+                               RelativePath="..\page\PlugInClient.h"
+                               >
+                       </File>
+                       <File
                                RelativePath="..\page\PoppupOpeningObserver.h"
                                >
                        </File>
index 9200e93..ccdab97 100644 (file)
                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 */; };
                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>"; };
                                8AF4E55811DC5A63000ED3DE /* PerformanceTiming.cpp */,
                                8AF4E55911DC5A63000ED3DE /* PerformanceTiming.h */,
                                8AF4E55A11DC5A63000ED3DE /* PerformanceTiming.idl */,
+                               31D591B116697A6C00E6BF02 /* PlugInClient.h */,
                                3772B09516535856000A49CA /* PopupOpeningObserver.h */,
                                B776D43C1104527500BEB0EC /* PrintContext.cpp */,
                                B776D43A1104525D00BEB0EC /* PrintContext.h */,
                                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 */,
                        );
index 5904cc8..0f9ee4c 100644 (file)
 #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"
@@ -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;
 
@@ -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()
@@ -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()
@@ -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
index c5bf6fa..2b843ce 100644 (file)
@@ -59,7 +59,10 @@ public:
     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);
@@ -103,6 +106,7 @@ private:
     RefPtr<RenderStyle> m_customStyleForPageCache;
     RefPtr<MouseEvent> m_pendingClickEventFromSnapshot;
     DeferrableOneShotTimer<HTMLPlugInImageElement> m_simulatedMouseClickTimer;
+    unsigned m_plugInOriginHash;
 };
 
 } // namespace WebCore
index 92ea973..d1ab7e5 100644 (file)
@@ -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);
 }
 
index 152daf8..6e06618 100644 (file)
@@ -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"
@@ -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)
@@ -198,6 +200,8 @@ Page::~Page()
     }
 
     m_editorClient->pageDestroyed();
+    if (m_plugInClient)
+        m_plugInClient->pageDestroyed();
     if (m_alternativeTextClient)
         m_alternativeTextClient->pageDestroyed();
 
@@ -1336,6 +1340,7 @@ Page::PageClients::PageClients()
     , editorClient(0)
     , dragClient(0)
     , inspectorClient(0)
+    , plugInClient(0)
     , validationMessageClient(0)
 {
 }
index 443ab26..fb3b788 100644 (file)
@@ -76,6 +76,7 @@ namespace WebCore {
     class MediaCanStartListener;
     class Node;
     class PageGroup;
+    class PlugInClient;
     class PluginData;
     class PluginViewBase;
     class PointerLockController;
@@ -127,6 +128,7 @@ namespace WebCore {
             EditorClient* editorClient;
             DragClient* dragClient;
             InspectorClient* inspectorClient;
+            PlugInClient* plugInClient;
             RefPtr<BackForwardList> backForwardClient;
             ValidationMessageClient* validationMessageClient;
         };
@@ -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(); }
@@ -406,6 +409,7 @@ namespace WebCore {
         RefPtr<RenderTheme> m_theme;
 
         EditorClient* m_editorClient;
+        PlugInClient* m_plugInClient;
         ValidationMessageClient* m_validationMessageClient;
 
         FeatureObserver m_featureObserver;
diff --git a/Source/WebCore/page/PlugInClient.h b/Source/WebCore/page/PlugInClient.h
new file mode 100644 (file)
index 0000000..cd65a70
--- /dev/null
@@ -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
index 6f221d9..695e561 100644 (file)
@@ -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())
@@ -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
index a0cde0c..e0f8d1f 100644 (file)
@@ -67,8 +67,6 @@ private:
     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;
index 47f5bdd..8de3191 100644 (file)
@@ -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
@@ -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
index bb6a957..2666bec 100644 (file)
@@ -1,3 +1,56 @@
+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.
+
+        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:
+
 2012-12-10  Anders Carlsson  <andersca@apple.com>
 
         Add WKPageSetInvalidMessageFunction stub
index dc26d9d..6b6939b 100644 (file)
@@ -816,6 +816,8 @@ webkit2_sources += \
        Source/WebKit2/UIProcess/Notifications/WebNotificationProvider.cpp \
        Source/WebKit2/UIProcess/Notifications/WebNotificationProvider.h \
        Source/WebKit2/UIProcess/PageClient.h \
+       Source/WebKit2/UIProcess/Plugins/PlugInAutoStartProvider.cpp \
+       Source/WebKit2/UIProcess/Plugins/PlugInAutoStartProvider.h \
        Source/WebKit2/UIProcess/Plugins/PluginInfoStore.cpp \
        Source/WebKit2/UIProcess/Plugins/PluginInfoStore.h \
        Source/WebKit2/UIProcess/Plugins/PluginProcessManager.cpp \
@@ -1150,6 +1152,8 @@ webkit2_sources += \
        Source/WebKit2/WebProcess/WebCoreSupport/WebNotificationClient.h \
        Source/WebKit2/WebProcess/WebCoreSupport/WebPlatformStrategies.cpp \
        Source/WebKit2/WebProcess/WebCoreSupport/WebPlatformStrategies.h \
+       Source/WebKit2/WebProcess/WebCoreSupport/WebPlugInClient.cpp \
+       Source/WebKit2/WebProcess/WebCoreSupport/WebPlugInClient.h \
        Source/WebKit2/WebProcess/WebCoreSupport/WebPopupMenu.cpp \
        Source/WebKit2/WebProcess/WebCoreSupport/WebPopupMenu.h \
        Source/WebKit2/WebProcess/WebCoreSupport/WebSearchPopupMenu.cpp \
index 221b031..047d170 100644 (file)
@@ -229,6 +229,7 @@ HEADERS += \
     UIProcess/PageClient.h \
     UIProcess/PageViewportController.h \
     UIProcess/PageViewportControllerClient.h \
+    UIProcess/Plugins/PlugInAutoStartProvider.h \
     UIProcess/Plugins/PluginInfoStore.h \
     UIProcess/Plugins/PluginProcessProxy.h \
     UIProcess/Plugins/PluginProcessManager.h \
@@ -361,6 +362,7 @@ HEADERS += \
     WebProcess/WebCoreSupport/WebNetworkInfoClient.h \
     WebProcess/WebCoreSupport/WebNotificationClient.h \
     WebProcess/WebCoreSupport/WebPlatformStrategies.h \
+    WebProcess/WebCoreSupport/WebPlugInClient.h \
     WebProcess/WebCoreSupport/WebPopupMenu.h \
     WebProcess/WebCoreSupport/WebSearchPopupMenu.h \
     WebProcess/WebCoreSupport/WebVibrationClient.h \
@@ -586,6 +588,7 @@ SOURCES += \
     UIProcess/Notifications/WebNotificationManagerProxy.cpp \
     UIProcess/Notifications/WebNotificationProvider.cpp \
     UIProcess/PageViewportController.cpp \
+    UIProcess/Plugins/PlugInAutoStartProvider.cpp \
     UIProcess/Plugins/PluginInfoStore.cpp \
     UIProcess/Plugins/PluginProcessProxy.cpp \
     UIProcess/Plugins/PluginProcessManager.cpp \
@@ -739,6 +742,7 @@ 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 \
diff --git a/Source/WebKit2/UIProcess/Plugins/PlugInAutoStartProvider.cpp b/Source/WebKit2/UIProcess/Plugins/PlugInAutoStartProvider.cpp
new file mode 100644 (file)
index 0000000..ff96213
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+ * 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.
+ */
+
+#include "config.h"
+#include "PlugInAutoStartProvider.h"
+
+#include "WebContext.h"
+#include "WebProcessMessages.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+PlugInAutoStartProvider::PlugInAutoStartProvider(WebContext* context)
+    : m_context(context)
+{
+}
+
+void PlugInAutoStartProvider::addAutoStartOrigin(const String& pageOrigin, unsigned plugInOriginHash)
+{
+    if (m_autoStartHashes.contains(plugInOriginHash))
+        return;
+    
+    AutoStartTable::iterator it = m_autoStartTable.find(pageOrigin);
+    if (it == m_autoStartTable.end())
+        it = m_autoStartTable.add(pageOrigin, HashSet<unsigned>()).iterator;
+    
+    it->value.add(plugInOriginHash);
+    m_autoStartHashes.add(plugInOriginHash);
+    m_context->sendToAllProcesses(Messages::WebProcess::DidAddPlugInAutoStartOrigin(plugInOriginHash));
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/Plugins/PlugInAutoStartProvider.h b/Source/WebKit2/UIProcess/Plugins/PlugInAutoStartProvider.h
new file mode 100644 (file)
index 0000000..22a9d58
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+ * 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 PlugInAutoStartProvider_h
+#define PlugInAutoStartProvider_h
+
+#include <wtf/HashMap.h>
+#include <wtf/HashSet.h>
+#include <wtf/Noncopyable.h>
+#include <wtf/text/StringHash.h>
+
+namespace WebKit {
+
+class WebContext;
+
+class PlugInAutoStartProvider {
+    WTF_MAKE_NONCOPYABLE(PlugInAutoStartProvider);
+public:
+    explicit PlugInAutoStartProvider(WebContext*);
+
+    void addAutoStartOrigin(const String& pageOrigin, unsigned plugInOriginHash);
+
+private:
+    WebContext* m_context;
+    
+    typedef HashMap<String, HashSet<unsigned>, CaseFoldingHash> AutoStartTable;
+    AutoStartTable m_autoStartTable;
+    HashSet<unsigned> m_autoStartHashes;
+};
+
+} // namespace WebKit
+
+#endif /* PlugInAutoStartProvider_h */
index 506aedc..31b1c99 100644 (file)
@@ -124,6 +124,7 @@ WebContext::WebContext(ProcessModel processModel, const String& injectedBundlePa
     , m_defaultPageGroup(WebPageGroup::create())
     , m_injectedBundlePath(injectedBundlePath)
     , m_visitedLinkProvider(this)
+    , m_plugInAutoStartProvider(this)
     , m_alwaysUsesComplexTextCodePath(false)
     , m_shouldUseFontSmoothing(true)
     , m_cacheModel(CacheModelDocumentViewer)
@@ -1082,4 +1083,9 @@ void WebContext::setJavaScriptGarbageCollectorTimerEnabled(bool flag)
     sendToAllProcesses(Messages::WebProcess::SetJavaScriptGarbageCollectorTimerEnabled(flag));
 }
 
+void WebContext::addPlugInAutoStartOriginHash(const String& pageOrigin, unsigned plugInOriginHash)
+{
+    m_plugInAutoStartProvider.addAutoStartOrigin(pageOrigin, plugInOriginHash);
+}
+
 } // namespace WebKit
index ed53504..849e772 100644 (file)
@@ -30,6 +30,7 @@
 #include "GenericCallback.h"
 #include "MessageReceiver.h"
 #include "MessageReceiverMap.h"
+#include "PlugInAutoStartProvider.h"
 #include "PluginInfoStore.h"
 #include "ProcessModel.h"
 #include "VisitedLinkProvider.h"
@@ -314,6 +315,8 @@ private:
     static void registerOcclusionNotificationHandlers();
 #endif
 
+    void addPlugInAutoStartOriginHash(const String& pageOrigin, unsigned plugInOriginHash);
+
     ProcessModel m_processModel;
     
     Vector<RefPtr<WebProcessProxy> > m_processes;
@@ -333,6 +336,7 @@ private:
     PluginInfoStore m_pluginInfoStore;
 #endif
     VisitedLinkProvider m_visitedLinkProvider;
+    PlugInAutoStartProvider m_plugInAutoStartProvider;
         
     HashSet<String> m_schemesToRegisterAsEmptyDocument;
     HashSet<String> m_schemesToRegisterAsSecure;
index 2664a5f..839cbcc 100644 (file)
@@ -51,4 +51,7 @@ messages -> WebContext {
     // any synchronous messages, and should be removed when <rdar://problem/8775115> is fixed.
     Dummy() -> (bool dummyReturn)
 #endif
+
+    # Plug-in messages.
+    void AddPlugInAutoStartOriginHash(WTF::String pageOrigin, uint32_t hash)
 }
index a2e702c..c4e0a78 100644 (file)
                31A2EC5614899C0900810D71 /* NotificationPermissionRequest.h in Headers */ = {isa = PBXBuildFile; fileRef = 31A2EC531489982500810D71 /* NotificationPermissionRequest.h */; };
                31A2EC74148D59CA00810D71 /* WKNotificationPermissionRequest.h in Headers */ = {isa = PBXBuildFile; fileRef = 31A2EC72148D59BB00810D71 /* WKNotificationPermissionRequest.h */; settings = {ATTRIBUTES = (Private, ); }; };
                31A2EC77148D662E00810D71 /* WKNotificationPermissionRequest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 31A2EC75148D65BB00810D71 /* WKNotificationPermissionRequest.cpp */; };
+               31A67E0C165B2A99006CBA66 /* PlugInAutoStartProvider.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 31A67E0A165B2A99006CBA66 /* PlugInAutoStartProvider.cpp */; };
+               31A67E0D165B2A99006CBA66 /* PlugInAutoStartProvider.h in Headers */ = {isa = PBXBuildFile; fileRef = 31A67E0B165B2A99006CBA66 /* PlugInAutoStartProvider.h */; };
                31BA924D148831260062EDB5 /* WebNotificationManagerMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 31BA9248148830810062EDB5 /* WebNotificationManagerMessageReceiver.cpp */; };
                31BA924E148831260062EDB5 /* WebNotificationManagerMessages.h in Headers */ = {isa = PBXBuildFile; fileRef = 31BA9249148830810062EDB5 /* WebNotificationManagerMessages.h */; };
+               31D5929E166E060000E6BF02 /* WebPlugInClient.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 31D5929C166E05FF00E6BF02 /* WebPlugInClient.cpp */; };
+               31D5929F166E060000E6BF02 /* WebPlugInClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 31D5929D166E060000E6BF02 /* WebPlugInClient.h */; };
                31EA25D2134F78C0005B1452 /* NativeWebMouseEventMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 31EA25D0134F78B2005B1452 /* NativeWebMouseEventMac.mm */; };
                330934471315B9220097A7BC /* WebCookieManagerMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 330934431315B9220097A7BC /* WebCookieManagerMessageReceiver.cpp */; };
                330934481315B9220097A7BC /* WebCookieManagerMessages.h in Headers */ = {isa = PBXBuildFile; fileRef = 330934441315B9220097A7BC /* WebCookieManagerMessages.h */; };
                31A2EC541489982E00810D71 /* NotificationPermissionRequest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NotificationPermissionRequest.cpp; sourceTree = "<group>"; };
                31A2EC72148D59BB00810D71 /* WKNotificationPermissionRequest.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WKNotificationPermissionRequest.h; sourceTree = "<group>"; };
                31A2EC75148D65BB00810D71 /* WKNotificationPermissionRequest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WKNotificationPermissionRequest.cpp; sourceTree = "<group>"; };
+               31A67E0A165B2A99006CBA66 /* PlugInAutoStartProvider.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PlugInAutoStartProvider.cpp; sourceTree = "<group>"; };
+               31A67E0B165B2A99006CBA66 /* PlugInAutoStartProvider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PlugInAutoStartProvider.h; sourceTree = "<group>"; };
                31BA9248148830810062EDB5 /* WebNotificationManagerMessageReceiver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebNotificationManagerMessageReceiver.cpp; sourceTree = "<group>"; };
                31BA9249148830810062EDB5 /* WebNotificationManagerMessages.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebNotificationManagerMessages.h; sourceTree = "<group>"; };
+               31D5929C166E05FF00E6BF02 /* WebPlugInClient.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebPlugInClient.cpp; sourceTree = "<group>"; };
+               31D5929D166E060000E6BF02 /* WebPlugInClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebPlugInClient.h; sourceTree = "<group>"; };
                31EA25D0134F78B2005B1452 /* NativeWebMouseEventMac.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = NativeWebMouseEventMac.mm; sourceTree = "<group>"; };
                31EA25D3134F78D6005B1452 /* NativeWebMouseEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NativeWebMouseEvent.h; sourceTree = "<group>"; };
                32DBCF5E0370ADEE00C91783 /* WebKit2Prefix.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebKit2Prefix.h; sourceTree = "<group>"; };
                        isa = PBXGroup;
                        children = (
                                1AEFCC0D11D01F41008219D3 /* mac */,
+                               31A67E0A165B2A99006CBA66 /* PlugInAutoStartProvider.cpp */,
+                               31A67E0B165B2A99006CBA66 /* PlugInAutoStartProvider.h */,
                                1AEFCC1111D01F96008219D3 /* PluginInfoStore.cpp */,
                                1AEFCC1011D01F96008219D3 /* PluginInfoStore.h */,
                                1A0EC602124A9F2C007EF4A5 /* PluginProcessManager.cpp */,
                                31099968146C71F50029DEB9 /* WebNotificationClient.h */,
                                1A3E736011CC2659007BD539 /* WebPlatformStrategies.cpp */,
                                1A3E735F11CC2659007BD539 /* WebPlatformStrategies.h */,
+                               31D5929C166E05FF00E6BF02 /* WebPlugInClient.cpp */,
+                               31D5929D166E060000E6BF02 /* WebPlugInClient.h */,
                                D3B9484211FF4B6500032B39 /* WebPopupMenu.cpp */,
                                D3B9484311FF4B6500032B39 /* WebPopupMenu.h */,
                                D3B9484411FF4B6500032B39 /* WebSearchPopupMenu.cpp */,
                                BC8ACA1316670D89004C1941 /* ObjCObjectGraph.h in Headers */,
                                BC8ACA1516670D89004C1941 /* ObjCObjectGraphCoders.h in Headers */,
                                E1513C67166EABB200149FCB /* ChildProcessProxy.h in Headers */,
+                               31A67E0D165B2A99006CBA66 /* PlugInAutoStartProvider.h in Headers */,
+                               31D5929F166E060000E6BF02 /* WebPlugInClient.h in Headers */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
                                BC8ACA1416670D89004C1941 /* ObjCObjectGraph.mm in Sources */,
                                BC8ACA1616670D89004C1941 /* ObjCObjectGraphCoders.mm in Sources */,
                                E1513C66166EABB200149FCB /* ChildProcessProxy.cpp in Sources */,
+                               31A67E0C165B2A99006CBA66 /* PlugInAutoStartProvider.cpp in Sources */,
+                               31D5929E166E060000E6BF02 /* WebPlugInClient.cpp in Sources */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/WebPlugInClient.cpp b/Source/WebKit2/WebProcess/WebCoreSupport/WebPlugInClient.cpp
new file mode 100644 (file)
index 0000000..891004b
--- /dev/null
@@ -0,0 +1,60 @@
+/*
+ * 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.
+ */
+
+#include "config.h"
+#include "WebPlugInClient.h"
+
+#include "Logging.h"
+#include "WebProcess.h"
+#include <wtf/text/CString.h>
+#include <wtf/text/WTFString.h>
+
+namespace WebKit {
+
+WebPlugInClient::WebPlugInClient(WebPage* page)
+    : m_page(page)
+{
+}
+
+WebPlugInClient::~WebPlugInClient()
+{
+}
+
+void WebPlugInClient::pageDestroyed()
+{
+    delete this;
+}
+
+bool WebPlugInClient::isAutoStartOrigin(unsigned plugInOriginHash)
+{
+    return WebProcess::shared().isPlugInAutoStartOrigin(plugInOriginHash);
+}
+
+void WebPlugInClient::addAutoStartOrigin(const String& pageOrigin, unsigned plugInOriginHash)
+{
+    WebProcess::shared().addPlugInAutoStartOrigin(pageOrigin, plugInOriginHash);
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/WebPlugInClient.h b/Source/WebKit2/WebProcess/WebCoreSupport/WebPlugInClient.h
new file mode 100644 (file)
index 0000000..ce422e1
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ * 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 WebPlugInClient_h
+#define WebPlugInClient_h
+
+#include <WebCore/PlugInClient.h>
+#include <wtf/HashSet.h>
+
+namespace WebKit {
+
+class WebPage;
+
+class WebPlugInClient : public WebCore::PlugInClient {
+public:
+    WebPlugInClient(WebPage*);
+    virtual ~WebPlugInClient();
+private:
+    virtual void pageDestroyed();
+    virtual bool isAutoStartOrigin(unsigned plugInOriginHash);
+    virtual void addAutoStartOrigin(const String& pageOrigin, unsigned plugInOriginHash);
+
+    WebPage *m_page;
+};
+
+} // namespace WebKit
+
+#endif /* WebPlugInClient */
index e45efda..102ff5e 100644 (file)
@@ -74,6 +74,7 @@
 #include "WebPageGroupProxy.h"
 #include "WebPageMessages.h"
 #include "WebPageProxyMessages.h"
+#include "WebPlugInClient.h"
 #include "WebPopupMenu.h"
 #include "WebPreferencesStore.h"
 #include "WebProcess.h"
@@ -301,7 +302,8 @@ WebPage::WebPage(uint64_t pageID, const WebPageCreationParameters& parameters)
 #if USE(AUTOCORRECTION_PANEL)
     pageClients.alternativeTextClient = new WebAlternativeTextClient(this);
 #endif
-    
+    pageClients.plugInClient = new WebPlugInClient(this);
+
     m_page = adoptPtr(new Page(pageClients));
 
 #if ENABLE(BATTERY_STATUS)
index aaf0fd7..c74c315 100644 (file)
@@ -29,6 +29,7 @@
 #include "DownloadManager.h"
 #include "InjectedBundle.h"
 #include "InjectedBundleUserMessageCoders.h"
+#include "Logging.h"
 #include "SandboxExtension.h"
 #include "StatisticsData.h"
 #include "WebApplicationCacheManager.h"
@@ -937,7 +938,27 @@ void WebProcess::clearPluginSiteData(const Vector<String>& pluginPaths, const Ve
     connection()->send(Messages::WebProcessProxy::DidClearPluginSiteData(callbackID), 0);
 }
 #endif
-    
+
+bool WebProcess::isPlugInAutoStartOrigin(unsigned plugInOriginHash)
+{
+    return m_plugInAutoStartOrigins.contains(plugInOriginHash);
+}
+
+void WebProcess::addPlugInAutoStartOrigin(const String& pageOrigin, unsigned plugInOriginHash)
+{
+    if (isPlugInAutoStartOrigin(plugInOriginHash)) {
+        LOG(Plugins, "Hash %x already exists as auto-start origin (request for %s)", plugInOriginHash, pageOrigin.utf8().data());
+        return;
+    }
+
+    connection()->send(Messages::WebContext::AddPlugInAutoStartOriginHash(pageOrigin, plugInOriginHash), 0);
+}
+
+void WebProcess::didAddPlugInAutoStartOrigin(unsigned plugInOriginHash)
+{
+    m_plugInAutoStartOrigins.add(plugInOriginHash);
+}
+
 static void fromCountedSetToHashMap(TypeCountSet* countedSet, HashMap<String, uint64_t>& map)
 {
     TypeCountSet::const_iterator end = countedSet->end();
index ef95d80..734c635 100644 (file)
@@ -151,6 +151,9 @@ public:
     void addVisitedLink(WebCore::LinkHash);
     bool isLinkVisited(WebCore::LinkHash) const;
 
+    bool isPlugInAutoStartOrigin(unsigned plugInOriginhash);
+    void addPlugInAutoStartOrigin(const String& pageOrigin, unsigned plugInOriginHash);
+
     bool fullKeyboardAccessEnabled() const { return m_fullKeyboardAccessEnabled; }
 
     WebFrame* webFrame(uint64_t) const;
@@ -238,6 +241,8 @@ private:
     void visitedLinkStateChanged(const Vector<WebCore::LinkHash>& linkHashes);
     void allVisitedLinkStateChanged();
 
+    void didAddPlugInAutoStartOrigin(unsigned plugInOriginHash);
+
     void platformSetCacheModel(CacheModel);
     static void calculateCacheSizes(CacheModel cacheModel, uint64_t memorySize, uint64_t diskFreeSize,
         unsigned& cacheTotalCapacity, unsigned& cacheMinDeadCapacity, unsigned& cacheMaxDeadCapacity, double& deadDecodedDataDeletionInterval,
@@ -329,6 +334,8 @@ private:
     VisitedLinkTable m_visitedLinkTable;
     bool m_shouldTrackVisitedLinks;
 
+    HashSet<unsigned> m_plugInAutoStartOrigins;
+
     bool m_hasSetCacheModel;
     CacheModel m_cacheModel;
 
index b8f9b37..01be395 100644 (file)
@@ -67,6 +67,7 @@ messages -> WebProcess {
     GetSitesWithPluginData(Vector<WTF::String> pluginPaths, uint64_t callbackID)
     ClearPluginSiteData(Vector<WTF::String> pluginPaths, Vector<WTF::String> sites, uint64_t flags, uint64_t maxAgeInSeconds, uint64_t callbackID)
 #endif
+    DidAddPlugInAutoStartOrigin(uint32_t hash)
 
 #if ENABLE(NETWORK_PROCESS)
     NetworkProcessCrashed() DispatchOnConnectionQueue
index 1588411..63e5b99 100755 (executable)
                                        >
                                </File>
                                <File
+                                       RelativePath="..\WebProcess\WebCoreSupport\WebPlugInClient.cpp"
+                                       >
+                               </File>
+                               <File
+                                       RelativePath="..\WebProcess\WebCoreSupport\WebPlugInClient.h"
+                                       >
+                               </File>
+                               <File
                                        RelativePath="..\WebProcess\WebCoreSupport\WebPopupMenu.cpp"
                                        >
                                </File>
                                Name="Plugins"
                                >
                                <File
+                                       RelativePath="..\UIProcess\Plugins\PlugInAutoStartProvider.cpp"
+                                       >
+                               </File>
+                               <File
+                                       RelativePath="..\UIProcess\Plugins\PlugInAutoStartProvider.h"
+                                       >
+                               </File>
+                               <File
                                        RelativePath="..\UIProcess\Plugins\PluginInfoStore.cpp"
                                        >
                                </File>