Title: [136694] trunk/Source/WebKit/blackberry
- Revision
- 136694
- Author
- [email protected]
- Date
- 2012-12-05 08:48:22 -0800 (Wed, 05 Dec 2012)
Log Message
[BlackBerry] GeolocationClientBB only holding the latest geolocation permission request
https://bugs.webkit.org/show_bug.cgi?id=104123
PR 256089
Patch by Otto Derek Cheung <[email protected]> on 2012-12-05
Reviewed by Yong Li.
Add a mapping between origin URL and it's geolocation object so we could
respond to the correct geolocation when libwebview responds with onPermission
in GeolocationClient.
Using the mapping, we could also prevent requestGeolocation requests from the same origin
to be sent twice. This prevents pages that hold two iframes to the same resource to request
geolocation permission on the same security origin twice.
Tested this by running a page that includes 2 or more iframes that requests geolocation
permission.
* WebCoreSupport/GeolocationClientBlackBerry.cpp:
(GeolocationClientBlackBerry::requestPermission):
(GeolocationClientBlackBerry::cancelPermissionRequest):
(GeolocationClientBlackBerry::onPermission):
* WebCoreSupport/GeolocationClientBlackBerry.h:
(GeolocationClientBlackBerry):
Modified Paths
Diff
Modified: trunk/Source/WebKit/blackberry/ChangeLog (136693 => 136694)
--- trunk/Source/WebKit/blackberry/ChangeLog 2012-12-05 16:36:19 UTC (rev 136693)
+++ trunk/Source/WebKit/blackberry/ChangeLog 2012-12-05 16:48:22 UTC (rev 136694)
@@ -1,3 +1,30 @@
+2012-12-05 Otto Derek Cheung <[email protected]>
+
+ [BlackBerry] GeolocationClientBB only holding the latest geolocation permission request
+ https://bugs.webkit.org/show_bug.cgi?id=104123
+
+ PR 256089
+
+ Reviewed by Yong Li.
+
+ Add a mapping between origin URL and it's geolocation object so we could
+ respond to the correct geolocation when libwebview responds with onPermission
+ in GeolocationClient.
+
+ Using the mapping, we could also prevent requestGeolocation requests from the same origin
+ to be sent twice. This prevents pages that hold two iframes to the same resource to request
+ geolocation permission on the same security origin twice.
+
+ Tested this by running a page that includes 2 or more iframes that requests geolocation
+ permission.
+
+ * WebCoreSupport/GeolocationClientBlackBerry.cpp:
+ (GeolocationClientBlackBerry::requestPermission):
+ (GeolocationClientBlackBerry::cancelPermissionRequest):
+ (GeolocationClientBlackBerry::onPermission):
+ * WebCoreSupport/GeolocationClientBlackBerry.h:
+ (GeolocationClientBlackBerry):
+
2012-12-05 Yongxin Dai <[email protected]>
[BlackBerry] Avoid showing FCC on empty text field in a different way
Modified: trunk/Source/WebKit/blackberry/WebCoreSupport/GeolocationClientBlackBerry.cpp (136693 => 136694)
--- trunk/Source/WebKit/blackberry/WebCoreSupport/GeolocationClientBlackBerry.cpp 2012-12-05 16:36:19 UTC (rev 136693)
+++ trunk/Source/WebKit/blackberry/WebCoreSupport/GeolocationClientBlackBerry.cpp 2012-12-05 16:48:22 UTC (rev 136694)
@@ -30,13 +30,6 @@
using namespace WebCore;
-static const BlackBerry::Platform::String frameOrigin(Frame* frame)
-{
- DOMWindow* window = frame->document()->domWindow();
- SecurityOrigin* origin = window->document()->securityOrigin();
- return BlackBerry::Platform::String(origin->toString().utf8().data());
-}
-
GeolocationClientBlackBerry::GeolocationClientBlackBerry(BlackBerry::WebKit::WebPagePrivate* webPagePrivate)
: m_webPagePrivate(webPagePrivate)
, m_accuracy(false)
@@ -80,13 +73,8 @@
return;
}
- DOMWindow* window = frame->document()->domWindow();
- if (!window)
- return;
+ const String origin = frame->document()->securityOrigin()->toString();
- const BlackBerry::Platform::String origin = frameOrigin(frame);
- m_pendingPermissionGeolocation = location;
-
// Check global location setting, if it is off then we request an infobar that invokes a location settings card.
// If it's on, then we request an infobar that allows the site to have permission to use geolocation.
if (!BlackBerry::Platform::GeolocationHandler::instance()->isGlobalServiceActive()) {
@@ -95,15 +83,48 @@
m_webPagePrivate->m_client->requestGlobalLocalServicePermission(this, origin);
BlackBerry::Platform::GeolocationHandler::instance()->setAskedUserForGlobalPermission();
} else
- onPermission(false);
+ location->setIsAllowed(false);
return;
}
- m_webPagePrivate->m_client->requestGeolocationPermission(this, origin);
+ // Add this geolocation permission request to our request map.
+ Vector<RefPtr<Geolocation> > geoRequestsForOrigin;
+ HashMap<String, Vector<RefPtr<Geolocation> > >::AddResult result = m_geolocationRequestMap.add(origin, geoRequestsForOrigin);
+ result.iterator->value.append(location);
+
+ // Avoid sending another request if the vector already has another geolocation pending for this origin in this page.
+ if (result.isNewEntry)
+ m_webPagePrivate->m_client->requestGeolocationPermission(this, origin);
}
void GeolocationClientBlackBerry::cancelPermissionRequest(Geolocation* location)
{
+ Frame* frame = location->frame();
+ if (!frame)
+ return;
+
+ const String origin = frame->document()->securityOrigin()->toString();
+
+ // Remove the geolocation from the pending permission map.
+ HashMap<String, Vector<RefPtr<Geolocation> > >::iterator it = m_geolocationRequestMap.find(origin);
+
+ ASSERT(it != m_geolocationRequestMap.end());
+ if (it == m_geolocationRequestMap.end())
+ return;
+
+ Vector<RefPtr<Geolocation> >* result = &(it->value);
+
+ size_t geolocationCount = result->size();
+ for (size_t i = 0; i < geolocationCount; ++i) {
+ if ((*result)[i].get() == location) {
+ result->remove(i);
+ // Remove this vector from the pending permission map is it doesn't contain anymore geo objects
+ if (result->isEmpty())
+ m_geolocationRequestMap.remove(origin);
+ break;
+ }
+ }
+
m_webPagePrivate->m_client->cancelGeolocationPermission();
}
@@ -121,10 +142,17 @@
GeolocationController::from(m_webPagePrivate->m_page)->errorOccurred(error.get());
}
-void GeolocationClientBlackBerry::onPermission(bool isAllowed)
+void GeolocationClientBlackBerry::onPermission(const BlackBerry::Platform::String& origin, bool isAllowed)
{
- if (m_pendingPermissionGeolocation)
- m_pendingPermissionGeolocation->setIsAllowed(isAllowed);
+ Vector<RefPtr<Geolocation> > pendingPermissionGeolocation = m_geolocationRequestMap.get(origin);
+
+ if (pendingPermissionGeolocation.isEmpty())
+ return;
+
+ size_t numberOfGeolocations = pendingPermissionGeolocation.size();
+ for (size_t i = 0; i < numberOfGeolocations; ++i)
+ pendingPermissionGeolocation[i]->setIsAllowed(isAllowed);
+ m_geolocationRequestMap.remove(origin);
}
void GeolocationClientBlackBerry::setEnableHighAccuracy(bool newAccuracy)
Modified: trunk/Source/WebKit/blackberry/WebCoreSupport/GeolocationClientBlackBerry.h (136693 => 136694)
--- trunk/Source/WebKit/blackberry/WebCoreSupport/GeolocationClientBlackBerry.h 2012-12-05 16:36:19 UTC (rev 136693)
+++ trunk/Source/WebKit/blackberry/WebCoreSupport/GeolocationClientBlackBerry.h 2012-12-05 16:48:22 UTC (rev 136694)
@@ -22,7 +22,9 @@
#include <BlackBerryPlatformGeoTracker.h>
#include <BlackBerryPlatformGeoTrackerListener.h>
#include <GeolocationClient.h>
+#include <wtf/HashMap.h>
#include <wtf/RefPtr.h>
+#include <wtf/text/WTFString.h>
namespace BlackBerry {
namespace WebKit {
@@ -48,12 +50,12 @@
virtual void onLocationUpdate(double timestamp, double latitude, double longitude, double accuracy, double altitude, bool altitudeValid, double altitudeAccuracy,
bool altitudeAccuracyValid, double speed, bool speedValid, double heading, bool headingValid);
virtual void onLocationError(const char* error);
- virtual void onPermission(bool isAllowed);
+ virtual void onPermission(const BlackBerry::Platform::String& origin, bool isAllowed);
private:
BlackBerry::WebKit::WebPagePrivate* m_webPagePrivate;
- RefPtr<Geolocation> m_pendingPermissionGeolocation;
RefPtr<GeolocationPosition> m_lastPosition;
+ HashMap<String, Vector<RefPtr<Geolocation> > > m_geolocationRequestMap;
bool m_accuracy;
bool m_isActive;
};
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes