return;
}
- // See if we have a record for this origin in the temporary permissions for
- // this tab. These take precedence over permanent permissions.
- PermissionsMap::const_iterator iter = m_temporaryPermissions.find(originString);
- PermissionsMap::const_iterator end = m_temporaryPermissions.end();
+ // See if we have a record for this origin in the permanent permissions.
+ // These take precedence over temporary permissions so that changes made
+ // from the browser settings work as intended.
+ PermissionsMap::const_iterator iter = s_permanentPermissions.find(originString);
+ PermissionsMap::const_iterator end = s_permanentPermissions.end();
if (iter != end) {
bool allow = iter->second;
makeAsynchronousCallbackToGeolocation(originString, allow);
return;
}
- // Check the permanent permisions.
- iter = s_permanentPermissions.find(originString);
- end = s_permanentPermissions.end();
+ // Check the temporary permisions.
+ iter = m_temporaryPermissions.find(originString);
+ end = m_temporaryPermissions.end();
if (iter != end) {
bool allow = iter->second;
makeAsynchronousCallbackToGeolocation(originString, allow);
{
if (remember) {
s_permanentPermissions.set(m_originInProgress, allow);
- // If we already have a temporary permission for this origin, remove it,
- // so that later clearing the permanent permission works as expected.
- m_temporaryPermissions.remove(origin);
} else {
// It's possible that another tab recorded a permanent permission for
// this origin while our request was in progress, but we record it
maybeStorePermanentPermissions();
}
+void GeolocationPermissions::allow(String origin)
+{
+ maybeLoadPermanentPermissions();
+ // We replace any existing permanent permission.
+ s_permanentPermissions.set(origin, true);
+ maybeStorePermanentPermissions();
+}
+
void GeolocationPermissions::clearAll()
{
maybeLoadPermanentPermissions();
void resetTemporaryPermissionStates();
// Static methods for use from Java. These are used to interact with the
- // browser settings menu.
+ // browser settings menu and to update the permanent permissions when
+ // system settings are changed.
typedef HashSet<WebCore::String> OriginSet;
static OriginSet getOrigins();
static bool getAllowed(WebCore::String origin);
static void clear(WebCore::String origin);
+ static void allow(WebCore::String origin);
static void clearAll();
static void setAlwaysDeny(bool deny);
GeolocationPermissions::clear(originString);
}
+static void allow(JNIEnv* env, jobject obj, jstring origin)
+{
+ WebCore::String originString = to_string(env, origin);
+ GeolocationPermissions::allow(originString);
+}
+
static void clearAll(JNIEnv* env, jobject obj)
{
GeolocationPermissions::clearAll();
(void*) getAllowed },
{ "nativeClear", "(Ljava/lang/String;)V",
(void*) clear },
+ { "nativeAllow", "(Ljava/lang/String;)V",
+ (void*) allow },
{ "nativeClearAll", "()V",
(void*) clearAll }
};