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)
commitd317d4eb056d52731245fc85601a3b0160afa0ac
treeef77eba62c6113ca3b9ebdf044ec13d77068633d
parent46163ab322965ea0904b1754680fadcede806e69
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.

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