- Revision
- 138729
- Author
- jon...@apple.com
- Date
- 2013-01-03 13:00:37 -0800 (Thu, 03 Jan 2013)
Log Message
Revert auto-start plugins to snapshotted plugins after a period of inactivity
https://bugs.webkit.org/show_bug.cgi?id=105973
<rdar://problem/12947865>
Reviewed by Brady Eidson.
Source/WebCore:
* html/HTMLPlugInElement.h:
(WebCore::HTMLPlugInElement::plugInOriginHash): Expose publicly for WebKit2.
Reorganize the protected members of the class.
* html/HTMLPlugInImageElement.h: Move the member to HTMLPlugInElement.
Source/WebKit2:
Change the set of origin hashes maintained by the web process to a hash map that associates
a timestamp for each hash. If the plug-in's origin is marked for auto-start, we also check
it against the timestamp. If the time is later, then we consider the entry stale, and snapshot
the plug-in instead.
But, if the user interacts with the plug-in, we delay that expiration timestamp out, so that
it expires a month from first interaction. To avoid too much chatter between the web processes
and UI process, we only update the timestamp if a day a passed since the last change to the
timestamp.
* WebProcess/Plugins/PluginView.h:
(PluginView): Add a member variable to flag whether the user had interacted with the plug-in.
* WebProcess/Plugins/PluginView.cpp:
(WebKit::PluginView::PluginView): Initialize the flag to false.
(WebKit::PluginView::handleEvent): We consider mouse down, up, wheel, context menu, and keyboard
events as user interaction. Do not consider mouse enter, leave, and move events as user
interaction. Also, remove unneeded comments.
(WebKit::PluginView::pluginDidReceiveUserInteraction): If this is the first time the function is
called, tell the web process, so that the expiration timestamp can be updated.
* WebProcess/WebProcess.messages.in: Update the messages to include the expiration time.
* WebProcess/WebProcess.h:
(WebProcess): Update the cached copy of the auto-start origins to include their expiration
timestamps. Update the message signatures. Add a function to update the expiration timestamp
for a specific origin. Rename plugInAutoStartOriginsChanged to resetPlugInAutoStartOrigins.
* WebProcess/WebProcess.cpp:
(WebKit::WebProcess::initializeWebProcess): Instead of individually adding the origins in the
provided vector, just call resetPlugInAutoStartOrigins().
(WebKit::WebProcess::isPlugInAutoStartOrigin): Check to see if the origin is in the table, and if
so, check the current time against the expiration time.
(WebKit::WebProcess::didAddPlugInAutoStartOrigin): Update the cached table.
(WebKit::WebProcess::resetPlugInAutoStartOrigins): Swap the tables between the provided parameter
and the member variable. We can safely do this because the function is called in two cases where
the parameter is afterwards thrown away: when a new web process is created, and when it is called
through an IPC message.
(WebKit::WebProcess::plugInDidReceiveUserInteraction): When invoked, we tell the UI process to
update the expiration time for the given origin if the time difference between the expiration
time and the current time is less than the threshold plugInAutoStartExpirationTimeUpdateThreshold.
* UIProcess/WebContext.messages.in: Add message that is called when the web process wants to
update the expiration timestamp for the plug-in origin.
* UIProcess/WebContext.cpp:
(WebKit::WebContext::plugInDidReceiveUserInteraction): Forward to the provider.
* UIProcess/WebContext.h:
* UIProcess/Plugins/PlugInAutoStartProvider.cpp:
(WebKit::expirationTimeFromNow): Returns a new time based on the current time + 1 month.
(WebKit::PlugInAutoStartProvider::addAutoStartOrigin): Refactor. Set the expiration time for the
added origin.
(WebKit::PlugInAutoStartProvider::autoStartOriginsCopy): Refactor.
(WebKit::PlugInAutoStartProvider::autoStartOriginsTableCopy): Refactor to include the expiration
times. Also, check the current time against the expiration time. If we are past the time, remove
the entry from the copy.
(WebKit::PlugInAutoStartProvider::setAutoStartOriginsTable): Refactor to extract and duplicate
the provided map of origins and expiration timestamps.
(WebKit::PlugInAutoStartProvider::didReceiveUserInteraction): Look for the origin hash. If found,
update the expiration time. Update all existing web processes with the new expiration time, and
tell the context client that the hashes have changed.
* UIProcess/Plugins/PlugInAutoStartProvider.h:
(PlugInAutoStartProvider): Change the m_autoStartHashes variable to a map of a hash to its domain
entry in the auto-start table. It is used to cross-reference the auto-start table and update
the origin's expiration time.
* Shared/WebProcessCreationParameters.h:
(WebProcessCreationParameters): Switch the creation parameter to seed the origin table to a map.
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (138728 => 138729)
--- trunk/Source/WebCore/ChangeLog 2013-01-03 20:22:47 UTC (rev 138728)
+++ trunk/Source/WebCore/ChangeLog 2013-01-03 21:00:37 UTC (rev 138729)
@@ -1,3 +1,16 @@
+2013-01-02 Jon Lee <jon...@apple.com>
+
+ Revert auto-start plugins to snapshotted plugins after a period of inactivity
+ https://bugs.webkit.org/show_bug.cgi?id=105973
+ <rdar://problem/12947865>
+
+ Reviewed by Brady Eidson.
+
+ * html/HTMLPlugInElement.h:
+ (WebCore::HTMLPlugInElement::plugInOriginHash): Expose publicly for WebKit2.
+ Reorganize the protected members of the class.
+ * html/HTMLPlugInImageElement.h: Move the member to HTMLPlugInElement.
+
2013-01-03 Alexis Menard <ale...@webkit.org>
Querying transition-timing-function value on the computed style does not return keywords when it should.
Modified: trunk/Source/WebCore/html/HTMLPlugInElement.h (138728 => 138729)
--- trunk/Source/WebCore/html/HTMLPlugInElement.h 2013-01-03 20:22:47 UTC (rev 138728)
+++ trunk/Source/WebCore/html/HTMLPlugInElement.h 2013-01-03 21:00:37 UTC (rev 138729)
@@ -59,6 +59,8 @@
virtual void updateSnapshot(PassRefPtr<Image>) { }
virtual void dispatchPendingMouseClick() { }
+ unsigned plugInOriginHash() const { return m_plugInOriginHash; }
+
#if ENABLE(NETSCAPE_PLUGIN_API)
NPObject* getNPObject();
#endif
@@ -80,10 +82,13 @@
virtual void collectStyleForPresentationAttribute(const Attribute&, StylePropertySet*) OVERRIDE;
virtual bool areAuthorShadowsAllowed() const OVERRIDE { return false; }
- bool m_inBeforeLoadEventHandler;
// Subclasses should use guardedDispatchBeforeLoadEvent instead of calling dispatchBeforeLoadEvent directly.
bool guardedDispatchBeforeLoadEvent(const String& sourceURL);
+ bool m_inBeforeLoadEventHandler;
+
+ unsigned m_plugInOriginHash;
+
private:
bool dispatchBeforeLoadEvent(const String& sourceURL); // Not implemented, generates a compile error if subclasses call this by mistake.
Modified: trunk/Source/WebCore/html/HTMLPlugInImageElement.h (138728 => 138729)
--- trunk/Source/WebCore/html/HTMLPlugInImageElement.h 2013-01-03 20:22:47 UTC (rev 138728)
+++ trunk/Source/WebCore/html/HTMLPlugInImageElement.h 2013-01-03 21:00:37 UTC (rev 138729)
@@ -108,7 +108,6 @@
RefPtr<RenderStyle> m_customStyleForPageCache;
RefPtr<MouseEvent> m_pendingClickEventFromSnapshot;
DeferrableOneShotTimer<HTMLPlugInImageElement> m_simulatedMouseClickTimer;
- unsigned m_plugInOriginHash;
};
} // namespace WebCore
Modified: trunk/Source/WebKit2/ChangeLog (138728 => 138729)
--- trunk/Source/WebKit2/ChangeLog 2013-01-03 20:22:47 UTC (rev 138728)
+++ trunk/Source/WebKit2/ChangeLog 2013-01-03 21:00:37 UTC (rev 138729)
@@ -1,3 +1,77 @@
+2013-01-02 Jon Lee <jon...@apple.com>
+
+ Revert auto-start plugins to snapshotted plugins after a period of inactivity
+ https://bugs.webkit.org/show_bug.cgi?id=105973
+ <rdar://problem/12947865>
+
+ Reviewed by Brady Eidson.
+
+ Change the set of origin hashes maintained by the web process to a hash map that associates
+ a timestamp for each hash. If the plug-in's origin is marked for auto-start, we also check
+ it against the timestamp. If the time is later, then we consider the entry stale, and snapshot
+ the plug-in instead.
+
+ But, if the user interacts with the plug-in, we delay that expiration timestamp out, so that
+ it expires a month from first interaction. To avoid too much chatter between the web processes
+ and UI process, we only update the timestamp if a day a passed since the last change to the
+ timestamp.
+
+ * WebProcess/Plugins/PluginView.h:
+ (PluginView): Add a member variable to flag whether the user had interacted with the plug-in.
+ * WebProcess/Plugins/PluginView.cpp:
+ (WebKit::PluginView::PluginView): Initialize the flag to false.
+ (WebKit::PluginView::handleEvent): We consider mouse down, up, wheel, context menu, and keyboard
+ events as user interaction. Do not consider mouse enter, leave, and move events as user
+ interaction. Also, remove unneeded comments.
+ (WebKit::PluginView::pluginDidReceiveUserInteraction): If this is the first time the function is
+ called, tell the web process, so that the expiration timestamp can be updated.
+
+ * WebProcess/WebProcess.messages.in: Update the messages to include the expiration time.
+ * WebProcess/WebProcess.h:
+ (WebProcess): Update the cached copy of the auto-start origins to include their expiration
+ timestamps. Update the message signatures. Add a function to update the expiration timestamp
+ for a specific origin. Rename plugInAutoStartOriginsChanged to resetPlugInAutoStartOrigins.
+ * WebProcess/WebProcess.cpp:
+ (WebKit::WebProcess::initializeWebProcess): Instead of individually adding the origins in the
+ provided vector, just call resetPlugInAutoStartOrigins().
+ (WebKit::WebProcess::isPlugInAutoStartOrigin): Check to see if the origin is in the table, and if
+ so, check the current time against the expiration time.
+ (WebKit::WebProcess::didAddPlugInAutoStartOrigin): Update the cached table.
+ (WebKit::WebProcess::resetPlugInAutoStartOrigins): Swap the tables between the provided parameter
+ and the member variable. We can safely do this because the function is called in two cases where
+ the parameter is afterwards thrown away: when a new web process is created, and when it is called
+ through an IPC message.
+ (WebKit::WebProcess::plugInDidReceiveUserInteraction): When invoked, we tell the UI process to
+ update the expiration time for the given origin if the time difference between the expiration
+ time and the current time is less than the threshold plugInAutoStartExpirationTimeUpdateThreshold.
+
+ * UIProcess/WebContext.messages.in: Add message that is called when the web process wants to
+ update the expiration timestamp for the plug-in origin.
+ * UIProcess/WebContext.cpp:
+ (WebKit::WebContext::plugInDidReceiveUserInteraction): Forward to the provider.
+ * UIProcess/WebContext.h:
+
+ * UIProcess/Plugins/PlugInAutoStartProvider.cpp:
+ (WebKit::expirationTimeFromNow): Returns a new time based on the current time + 1 month.
+ (WebKit::PlugInAutoStartProvider::addAutoStartOrigin): Refactor. Set the expiration time for the
+ added origin.
+ (WebKit::PlugInAutoStartProvider::autoStartOriginsCopy): Refactor.
+ (WebKit::PlugInAutoStartProvider::autoStartOriginsTableCopy): Refactor to include the expiration
+ times. Also, check the current time against the expiration time. If we are past the time, remove
+ the entry from the copy.
+ (WebKit::PlugInAutoStartProvider::setAutoStartOriginsTable): Refactor to extract and duplicate
+ the provided map of origins and expiration timestamps.
+ (WebKit::PlugInAutoStartProvider::didReceiveUserInteraction): Look for the origin hash. If found,
+ update the expiration time. Update all existing web processes with the new expiration time, and
+ tell the context client that the hashes have changed.
+ * UIProcess/Plugins/PlugInAutoStartProvider.h:
+ (PlugInAutoStartProvider): Change the m_autoStartHashes variable to a map of a hash to its domain
+ entry in the auto-start table. It is used to cross-reference the auto-start table and update
+ the origin's expiration time.
+
+ * Shared/WebProcessCreationParameters.h:
+ (WebProcessCreationParameters): Switch the creation parameter to seed the origin table to a map.
+
2013-01-03 Alexis Menard <ale...@webkit.org>
Querying transition-timing-function value on the computed style does not return keywords when it should.
Modified: trunk/Source/WebKit2/Shared/WebProcessCreationParameters.h (138728 => 138729)
--- trunk/Source/WebKit2/Shared/WebProcessCreationParameters.h 2013-01-03 20:22:47 UTC (rev 138728)
+++ trunk/Source/WebKit2/Shared/WebProcessCreationParameters.h 2013-01-03 21:00:37 UTC (rev 138729)
@@ -144,7 +144,7 @@
bool usesNetworkProcess;
#endif
- Vector<unsigned> plugInAutoStartOrigins;
+ HashMap<unsigned, double> plugInAutoStartOrigins;
};
} // namespace WebKit
Modified: trunk/Source/WebKit2/UIProcess/Plugins/PlugInAutoStartProvider.cpp (138728 => 138729)
--- trunk/Source/WebKit2/UIProcess/Plugins/PlugInAutoStartProvider.cpp 2013-01-03 20:22:47 UTC (rev 138728)
+++ trunk/Source/WebKit2/UIProcess/Plugins/PlugInAutoStartProvider.cpp 2013-01-03 21:00:37 UTC (rev 138729)
@@ -32,6 +32,8 @@
using namespace WebCore;
+static const double plugInAutoStartExpirationTimeThreshold = 30 * 24 * 60;
+
namespace WebKit {
PlugInAutoStartProvider::PlugInAutoStartProvider(WebContext* context)
@@ -39,6 +41,11 @@
{
}
+static double expirationTimeFromNow()
+{
+ return currentTime() + plugInAutoStartExpirationTimeThreshold;
+}
+
void PlugInAutoStartProvider::addAutoStartOrigin(const String& pageOrigin, unsigned plugInOriginHash)
{
if (m_autoStartHashes.contains(plugInOriginHash))
@@ -46,32 +53,44 @@
AutoStartTable::iterator it = m_autoStartTable.find(pageOrigin);
if (it == m_autoStartTable.end())
- it = m_autoStartTable.add(pageOrigin, HashSet<unsigned>()).iterator;
+ it = m_autoStartTable.add(pageOrigin, HashMap<unsigned, double>()).iterator;
+
+ double expirationTime = expirationTimeFromNow();
+ it->value.set(plugInOriginHash, expirationTime);
+ m_autoStartHashes.set(plugInOriginHash, pageOrigin);
- it->value.add(plugInOriginHash);
- m_autoStartHashes.add(plugInOriginHash);
- m_context->sendToAllProcesses(Messages::WebProcess::DidAddPlugInAutoStartOrigin(plugInOriginHash));
+ m_context->sendToAllProcesses(Messages::WebProcess::DidAddPlugInAutoStartOrigin(plugInOriginHash, expirationTime));
m_context->client().plugInAutoStartOriginHashesChanged(m_context);
}
-Vector<unsigned> PlugInAutoStartProvider::autoStartOriginsCopy() const
+HashMap<unsigned, double> PlugInAutoStartProvider::autoStartOriginsCopy() const
{
- Vector<unsigned> copyVector;
- copyToVector(m_autoStartHashes, copyVector);
- return copyVector;
+ HashMap<unsigned, double> copyMap;
+ AutoStartTable::const_iterator end = m_autoStartTable.end();
+ for (AutoStartTable::const_iterator it = m_autoStartTable.begin(); it != end; ++it) {
+ HashMap<unsigned, double>::const_iterator mapEnd = it->value.end();
+ for (HashMap<unsigned, double>::const_iterator mapIt = it->value.begin(); mapIt != mapEnd; ++mapIt)
+ copyMap.set(mapIt->key, mapIt->value);
+ }
+ return copyMap;
}
PassRefPtr<ImmutableDictionary> PlugInAutoStartProvider::autoStartOriginsTableCopy() const
{
ImmutableDictionary::MapType map;
AutoStartTable::const_iterator end = m_autoStartTable.end();
+ double now = currentTime();
for (AutoStartTable::const_iterator it = m_autoStartTable.begin(); it != end; ++it) {
- Vector<RefPtr<APIObject> > hashes;
- HashSet<unsigned>::iterator valueEnd = it->value.end();
- for (HashSet<unsigned>::iterator valueIt = it->value.begin(); valueIt != valueEnd; ++valueIt)
- hashes.append(WebUInt64::create(*valueIt));
+ ImmutableDictionary::MapType hashMap;
+ HashMap<unsigned, double>::const_iterator valueEnd = it->value.end();
+ for (HashMap<unsigned, double>::const_iterator valueIt = it->value.begin(); valueIt != valueEnd; ++valueIt) {
+ if (now > valueIt->value)
+ continue;
+ hashMap.set(String::number(valueIt->key), WebDouble::create(valueIt->value));
+ }
- map.set(it->key, ImmutableArray::adopt(hashes));
+ if (hashMap.size())
+ map.set(it->key, ImmutableDictionary::adopt(hashMap));
}
return ImmutableDictionary::adopt(map);
@@ -81,24 +100,46 @@
{
m_autoStartTable.clear();
m_autoStartHashes.clear();
- Vector<unsigned> hashVector;
+ HashMap<unsigned, double> hashMap;
ImmutableDictionary::MapType::const_iterator end = table.map().end();
for (ImmutableDictionary::MapType::const_iterator it = table.map().begin(); it != end; ++it) {
- HashSet<unsigned> hashes;
- ImmutableArray* tableHashes = static_cast<ImmutableArray*>(it->value.get());
- size_t hashSetSize = tableHashes->size();
- for (size_t i = 0; i < hashSetSize; ++i) {
- unsigned hash = static_cast<unsigned>(tableHashes->at<WebUInt64>(i)->value());
- hashes.add(hash);
- m_autoStartHashes.add(hash);
- hashVector.append(hash);
+ HashMap<unsigned, double> hashes;
+ ImmutableDictionary* hashesForPage = static_cast<ImmutableDictionary*>(it->value.get());
+ ImmutableDictionary::MapType::const_iterator hashEnd = hashesForPage->map().end();
+ for (ImmutableDictionary::MapType::const_iterator hashIt = hashesForPage->map().begin(); hashIt != hashEnd; ++hashIt) {
+ bool ok;
+ unsigned hash = hashIt->key.toUInt(&ok);
+ if (!ok)
+ continue;
+
+ if (hashIt->value->type() != WebDouble::APIType)
+ continue;
+
+ double expirationTime = static_cast<WebDouble*>(hashIt->value.get())->value();
+ hashes.set(hash, expirationTime);
+ hashMap.set(hash, expirationTime);
+ m_autoStartHashes.set(hash, it->key);
}
- m_autoStartTable.add(it->key, hashes);
+ m_autoStartTable.set(it->key, hashes);
}
- m_context->sendToAllProcesses(Messages::WebProcess::PlugInAutoStartOriginsChanged(hashVector));
+ m_context->sendToAllProcesses(Messages::WebProcess::ResetPlugInAutoStartOrigins(hashMap));
}
+void PlugInAutoStartProvider::didReceiveUserInteraction(unsigned plugInOriginHash)
+{
+ HashMap<unsigned, String>::const_iterator it = m_autoStartHashes.find(plugInOriginHash);
+ if (it == m_autoStartHashes.end()) {
+ ASSERT_NOT_REACHED();
+ return;
+ }
+
+ double newExpirationTime = expirationTimeFromNow();
+ m_autoStartTable.find(it->value)->value.set(plugInOriginHash, newExpirationTime);
+ m_context->sendToAllProcesses(Messages::WebProcess::DidAddPlugInAutoStartOrigin(plugInOriginHash, newExpirationTime));
+ m_context->client().plugInAutoStartOriginHashesChanged(m_context);
+}
+
} // namespace WebKit
Modified: trunk/Source/WebKit2/UIProcess/Plugins/PlugInAutoStartProvider.h (138728 => 138729)
--- trunk/Source/WebKit2/UIProcess/Plugins/PlugInAutoStartProvider.h 2013-01-03 20:22:47 UTC (rev 138728)
+++ trunk/Source/WebKit2/UIProcess/Plugins/PlugInAutoStartProvider.h 2013-01-03 21:00:37 UTC (rev 138729)
@@ -43,16 +43,17 @@
void addAutoStartOrigin(const String& pageOrigin, unsigned plugInOriginHash);
- Vector<unsigned> autoStartOriginsCopy() const;
+ HashMap<unsigned, double> autoStartOriginsCopy() const;
PassRefPtr<ImmutableDictionary> autoStartOriginsTableCopy() const;
void setAutoStartOriginsTable(ImmutableDictionary&);
+ void didReceiveUserInteraction(unsigned plugInOriginHash);
private:
WebContext* m_context;
- typedef HashMap<String, HashSet<unsigned>, CaseFoldingHash> AutoStartTable;
+ typedef HashMap<String, HashMap<unsigned, double>, CaseFoldingHash> AutoStartTable;
AutoStartTable m_autoStartTable;
- HashSet<unsigned> m_autoStartHashes;
+ HashMap<unsigned, String> m_autoStartHashes;
};
} // namespace WebKit
Modified: trunk/Source/WebKit2/UIProcess/WebContext.cpp (138728 => 138729)
--- trunk/Source/WebKit2/UIProcess/WebContext.cpp 2013-01-03 20:22:47 UTC (rev 138728)
+++ trunk/Source/WebKit2/UIProcess/WebContext.cpp 2013-01-03 21:00:37 UTC (rev 138729)
@@ -1143,6 +1143,11 @@
m_plugInAutoStartProvider.addAutoStartOrigin(pageOrigin, plugInOriginHash);
}
+void WebContext::plugInDidReceiveUserInteraction(unsigned plugInOriginHash)
+{
+ m_plugInAutoStartProvider.didReceiveUserInteraction(plugInOriginHash);
+}
+
PassRefPtr<ImmutableDictionary> WebContext::plugInAutoStartOriginHashes() const
{
return m_plugInAutoStartProvider.autoStartOriginsTableCopy();
Modified: trunk/Source/WebKit2/UIProcess/WebContext.h (138728 => 138729)
--- trunk/Source/WebKit2/UIProcess/WebContext.h 2013-01-03 20:22:47 UTC (rev 138728)
+++ trunk/Source/WebKit2/UIProcess/WebContext.h 2013-01-03 21:00:37 UTC (rev 138729)
@@ -366,6 +366,7 @@
#endif
void addPlugInAutoStartOriginHash(const String& pageOrigin, unsigned plugInOriginHash);
+ void plugInDidReceiveUserInteraction(unsigned plugInOriginHash);
CoreIPC::MessageReceiverMap m_messageReceiverMap;
Modified: trunk/Source/WebKit2/UIProcess/WebContext.messages.in (138728 => 138729)
--- trunk/Source/WebKit2/UIProcess/WebContext.messages.in 2013-01-03 20:22:47 UTC (rev 138728)
+++ trunk/Source/WebKit2/UIProcess/WebContext.messages.in 2013-01-03 21:00:37 UTC (rev 138729)
@@ -54,4 +54,5 @@
# Plug-in messages.
void AddPlugInAutoStartOriginHash(WTF::String pageOrigin, uint32_t hash)
+ void PlugInDidReceiveUserInteraction(uint32_t hash)
}
Modified: trunk/Source/WebKit2/WebProcess/Plugins/PluginView.cpp (138728 => 138729)
--- trunk/Source/WebKit2/WebProcess/Plugins/PluginView.cpp 2013-01-03 20:22:47 UTC (rev 138728)
+++ trunk/Source/WebKit2/WebProcess/Plugins/PluginView.cpp 2013-01-03 21:00:37 UTC (rev 138729)
@@ -275,6 +275,7 @@
, m_manualStreamState(StreamStateInitial)
, m_pluginSnapshotTimer(this, &PluginView::pluginSnapshotTimerFired, pluginSnapshotTimerDelay)
, m_countSnapshotRetries(0)
+ , m_didReceiveUserInteraction(false)
, m_pageScaleFactor(1)
{
m_webPage->addPluginView(this);
@@ -810,8 +811,6 @@
if ((event->type() == eventNames().mousemoveEvent && currentEvent->type() == WebEvent::MouseMove)
|| (event->type() == eventNames().mousedownEvent && currentEvent->type() == WebEvent::MouseDown)
|| (event->type() == eventNames().mouseupEvent && currentEvent->type() == WebEvent::MouseUp)) {
- // We have a mouse event.
-
// FIXME: Clicking in a scroll bar should not change focus.
if (currentEvent->type() == WebEvent::MouseDown) {
focusPluginElement();
@@ -820,22 +819,22 @@
frame()->eventHandler()->setCapturingMouseEventsNode(0);
didHandleEvent = m_plugin->handleMouseEvent(static_cast<const WebMouseEvent&>(*currentEvent));
+ if (event->type() != eventNames().mousemoveEvent)
+ pluginDidReceiveUserInteraction();
} else if (event->type() == eventNames().mousewheelEvent && currentEvent->type() == WebEvent::Wheel && m_plugin->wantsWheelEvents()) {
- // We have a wheel event.
didHandleEvent = m_plugin->handleWheelEvent(static_cast<const WebWheelEvent&>(*currentEvent));
- } else if (event->type() == eventNames().mouseoverEvent && currentEvent->type() == WebEvent::MouseMove) {
- // We have a mouse enter event.
+ pluginDidReceiveUserInteraction();
+ } else if (event->type() == eventNames().mouseoverEvent && currentEvent->type() == WebEvent::MouseMove)
didHandleEvent = m_plugin->handleMouseEnterEvent(static_cast<const WebMouseEvent&>(*currentEvent));
- } else if (event->type() == eventNames().mouseoutEvent && currentEvent->type() == WebEvent::MouseMove) {
- // We have a mouse leave event.
+ else if (event->type() == eventNames().mouseoutEvent && currentEvent->type() == WebEvent::MouseMove)
didHandleEvent = m_plugin->handleMouseLeaveEvent(static_cast<const WebMouseEvent&>(*currentEvent));
- } else if (event->type() == eventNames().contextmenuEvent && currentEvent->type() == WebEvent::MouseDown) {
- // We have a context menu event.
+ else if (event->type() == eventNames().contextmenuEvent && currentEvent->type() == WebEvent::MouseDown) {
didHandleEvent = m_plugin->handleContextMenuEvent(static_cast<const WebMouseEvent&>(*currentEvent));
+ pluginDidReceiveUserInteraction();
} else if ((event->type() == eventNames().keydownEvent && currentEvent->type() == WebEvent::KeyDown)
|| (event->type() == eventNames().keyupEvent && currentEvent->type() == WebEvent::KeyUp)) {
- // We have a keyboard event.
didHandleEvent = m_plugin->handleKeyboardEvent(static_cast<const WebKeyboardEvent&>(*currentEvent));
+ pluginDidReceiveUserInteraction();
}
if (didHandleEvent)
@@ -1608,4 +1607,13 @@
return m_plugin->shouldAlwaysAutoStart();
}
+void PluginView::pluginDidReceiveUserInteraction()
+{
+ if (m_didReceiveUserInteraction)
+ return;
+
+ m_didReceiveUserInteraction = true;
+ WebProcess::shared().plugInDidReceiveUserInteraction(m_pluginElement->plugInOriginHash());
+}
+
} // namespace WebKit
Modified: trunk/Source/WebKit2/WebProcess/Plugins/PluginView.h (138728 => 138729)
--- trunk/Source/WebKit2/WebProcess/Plugins/PluginView.h 2013-01-03 20:22:47 UTC (rev 138728)
+++ trunk/Source/WebKit2/WebProcess/Plugins/PluginView.h 2013-01-03 21:00:37 UTC (rev 138729)
@@ -128,6 +128,7 @@
void redeliverManualStream();
void pluginSnapshotTimerFired(WebCore::DeferrableOneShotTimer<PluginView>*);
+ void pluginDidReceiveUserInteraction();
// WebCore::PluginViewBase
#if PLATFORM(MAC)
@@ -257,6 +258,7 @@
// This timer is used when plugin snapshotting is enabled, to capture a plugin placeholder.
WebCore::DeferrableOneShotTimer<PluginView> m_pluginSnapshotTimer;
unsigned m_countSnapshotRetries;
+ bool m_didReceiveUserInteraction;
double m_pageScaleFactor;
};
Modified: trunk/Source/WebKit2/WebProcess/WebProcess.cpp (138728 => 138729)
--- trunk/Source/WebKit2/WebProcess/WebProcess.cpp 2013-01-03 20:22:47 UTC (rev 138728)
+++ trunk/Source/WebKit2/WebProcess/WebProcess.cpp 2013-01-03 21:00:37 UTC (rev 138729)
@@ -77,6 +77,7 @@
#include <WebCore/SecurityOrigin.h>
#include <WebCore/Settings.h>
#include <WebCore/StorageTracker.h>
+#include <wtf/CurrentTime.h>
#include <wtf/HashCountedSet.h>
#include <wtf/PassRefPtr.h>
@@ -123,6 +124,9 @@
using namespace JSC;
using namespace WebCore;
+// This should be less than plugInAutoStartExpirationTimeThreshold in PlugInAutoStartProvider.
+static const double plugInAutoStartExpirationTimeUpdateThreshold = 29 * 24 * 60;
+
namespace WebKit {
WebProcess& WebProcess::shared()
@@ -318,8 +322,7 @@
#endif
setTerminationTimeout(parameters.terminationTimeout);
- for (size_t i = 0; i < parameters.plugInAutoStartOrigins.size(); ++i)
- didAddPlugInAutoStartOrigin(parameters.plugInAutoStartOrigins[i]);
+ resetPlugInAutoStartOrigins(parameters.plugInAutoStartOrigins);
}
#if ENABLE(NETWORK_PROCESS)
@@ -782,7 +785,10 @@
bool WebProcess::isPlugInAutoStartOrigin(unsigned plugInOriginHash)
{
- return m_plugInAutoStartOrigins.contains(plugInOriginHash);
+ HashMap<unsigned, double>::const_iterator it = m_plugInAutoStartOrigins.find(plugInOriginHash);
+ if (it == m_plugInAutoStartOrigins.end())
+ return false;
+ return currentTime() < it->value;
}
void WebProcess::addPlugInAutoStartOrigin(const String& pageOrigin, unsigned plugInOriginHash)
@@ -795,18 +801,32 @@
connection()->send(Messages::WebContext::AddPlugInAutoStartOriginHash(pageOrigin, plugInOriginHash), 0);
}
-void WebProcess::didAddPlugInAutoStartOrigin(unsigned plugInOriginHash)
+void WebProcess::didAddPlugInAutoStartOrigin(unsigned plugInOriginHash, double expirationTime)
{
- m_plugInAutoStartOrigins.add(plugInOriginHash);
+ // When called, some web process (which also might be this one) added the origin for auto-starting,
+ // or received user interaction.
+ // Set the bit to avoid having redundantly call into the UI process upon user interaction.
+ m_plugInAutoStartOrigins.set(plugInOriginHash, expirationTime);
}
-void WebProcess::plugInAutoStartOriginsChanged(const Vector<unsigned>& hashes)
+void WebProcess::resetPlugInAutoStartOrigins(const HashMap<unsigned, double>& hashes)
{
- m_plugInAutoStartOrigins.clear();
- for (size_t i = 0; i < hashes.size(); ++i)
- didAddPlugInAutoStartOrigin(hashes[i]);
+ m_plugInAutoStartOrigins.swap(const_cast<HashMap<unsigned, double>&>(hashes));
}
+void WebProcess::plugInDidReceiveUserInteraction(unsigned plugInOriginHash)
+{
+ if (!plugInOriginHash)
+ return;
+
+ HashMap<unsigned, double>::iterator it = m_plugInAutoStartOrigins.find(plugInOriginHash);
+ ASSERT(it != m_plugInAutoStartOrigins.end());
+ if (it->value - currentTime() > plugInAutoStartExpirationTimeUpdateThreshold)
+ return;
+
+ connection()->send(Messages::WebContext::PlugInDidReceiveUserInteraction(plugInOriginHash), 0);
+}
+
static void fromCountedSetToHashMap(TypeCountSet* countedSet, HashMap<String, uint64_t>& map)
{
TypeCountSet::const_iterator end = countedSet->end();
Modified: trunk/Source/WebKit2/WebProcess/WebProcess.h (138728 => 138729)
--- trunk/Source/WebKit2/WebProcess/WebProcess.h 2013-01-03 20:22:47 UTC (rev 138728)
+++ trunk/Source/WebKit2/WebProcess/WebProcess.h 2013-01-03 21:00:37 UTC (rev 138729)
@@ -153,8 +153,9 @@
void addVisitedLink(WebCore::LinkHash);
bool isLinkVisited(WebCore::LinkHash) const;
- bool isPlugInAutoStartOrigin(unsigned plugInOriginhash);
+ bool isPlugInAutoStartOrigin(unsigned plugInOriginHash);
void addPlugInAutoStartOrigin(const String& pageOrigin, unsigned plugInOriginHash);
+ void plugInDidReceiveUserInteraction(unsigned plugInOriginHash);
bool fullKeyboardAccessEnabled() const { return m_fullKeyboardAccessEnabled; }
@@ -238,8 +239,8 @@
void visitedLinkStateChanged(const Vector<WebCore::LinkHash>& linkHashes);
void allVisitedLinkStateChanged();
- void didAddPlugInAutoStartOrigin(unsigned plugInOriginHash);
- void plugInAutoStartOriginsChanged(const Vector<unsigned>& hashes);
+ void didAddPlugInAutoStartOrigin(unsigned plugInOriginHash, double expirationTime);
+ void resetPlugInAutoStartOrigins(const HashMap<unsigned, double>& hashes);
void platformSetCacheModel(CacheModel);
void platformClearResourceCaches(ResourceCachesToClear);
@@ -321,7 +322,7 @@
VisitedLinkTable m_visitedLinkTable;
bool m_shouldTrackVisitedLinks;
- HashSet<unsigned> m_plugInAutoStartOrigins;
+ HashMap<unsigned, double> m_plugInAutoStartOrigins;
bool m_hasSetCacheModel;
CacheModel m_cacheModel;
Modified: trunk/Source/WebKit2/WebProcess/WebProcess.messages.in (138728 => 138729)
--- trunk/Source/WebKit2/WebProcess/WebProcess.messages.in 2013-01-03 20:22:47 UTC (rev 138728)
+++ trunk/Source/WebKit2/WebProcess/WebProcess.messages.in 2013-01-03 21:00:37 UTC (rev 138729)
@@ -70,8 +70,8 @@
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)
- PlugInAutoStartOriginsChanged(Vector<uint32_t> hashes)
+ DidAddPlugInAutoStartOrigin(uint32_t hash, double expirationTime)
+ ResetPlugInAutoStartOrigins(HashMap<uint32_t,double> hashes)
#if ENABLE(PLUGIN_PROCESS)
PluginProcessCrashed(String pluginProcess, uint32_t processType) DispatchOnConnectionQueue