diff options
Diffstat (limited to 'WebKit')
5 files changed, 23 insertions, 7 deletions
diff --git a/WebKit/android/WebCoreSupport/ChromeClientAndroid.cpp b/WebKit/android/WebCoreSupport/ChromeClientAndroid.cpp index 6f8b7fe..1c17ffe 100644 --- a/WebKit/android/WebCoreSupport/ChromeClientAndroid.cpp +++ b/WebKit/android/WebCoreSupport/ChromeClientAndroid.cpp @@ -357,6 +357,11 @@ void ChromeClientAndroid::provideGeolocationPermissions(const String &origin, bo m_geolocationPermissions->providePermissionState(origin, allow, remember); } +void ChromeClientAndroid::storeGeolocationPermissions() +{ + GeolocationPermissions::maybeStorePermanentPermissions(); +} + void ChromeClientAndroid::onMainFrameLoadStarted() { if (m_geolocationPermissions.get()) diff --git a/WebKit/android/WebCoreSupport/ChromeClientAndroid.h b/WebKit/android/WebCoreSupport/ChromeClientAndroid.h index 4ac3d6c..9976326 100644 --- a/WebKit/android/WebCoreSupport/ChromeClientAndroid.h +++ b/WebKit/android/WebCoreSupport/ChromeClientAndroid.h @@ -127,6 +127,7 @@ namespace android { virtual void requestGeolocationPermissionForFrame(Frame*, Geolocation*); // Android-specific void provideGeolocationPermissions(const String &origin, bool allow, bool remember); + void storeGeolocationPermissions(); void onMainFrameLoadStarted(); virtual void runOpenPanel(Frame*, PassRefPtr<FileChooser>); diff --git a/WebKit/android/WebCoreSupport/GeolocationPermissions.cpp b/WebKit/android/WebCoreSupport/GeolocationPermissions.cpp index b77edd3..62df3c0 100755 --- a/WebKit/android/WebCoreSupport/GeolocationPermissions.cpp +++ b/WebKit/android/WebCoreSupport/GeolocationPermissions.cpp @@ -62,7 +62,6 @@ GeolocationPermissions::~GeolocationPermissions() { size_t index = s_instances.find(this); s_instances.remove(index); - maybeStorePermanentPermissions(); } void GeolocationPermissions::queryPermissionState(Frame* frame) @@ -256,7 +255,6 @@ void GeolocationPermissions::clear(String origin) PermissionsMap::iterator iter = s_permanentPermissions.find(origin); if (iter != s_permanentPermissions.end()) s_permanentPermissions.remove(iter); - maybeStorePermanentPermissions(); } void GeolocationPermissions::allow(String origin) @@ -264,14 +262,12 @@ void GeolocationPermissions::allow(String origin) maybeLoadPermanentPermissions(); // We replace any existing permanent permission. s_permanentPermissions.set(origin, true); - maybeStorePermanentPermissions(); } void GeolocationPermissions::clearAll() { maybeLoadPermanentPermissions(); s_permanentPermissions.clear(); - maybeStorePermanentPermissions(); } void GeolocationPermissions::maybeLoadPermanentPermissions() @@ -306,8 +302,11 @@ void GeolocationPermissions::maybeLoadPermanentPermissions() void GeolocationPermissions::maybeStorePermanentPermissions() { - // If no instances remain, we need to store the permanent permissions. - if (s_instances.size() > 0) + // Protect against the case where we haven't yet loaded permissions, as + // saving in this case would overwrite the stored permissions with the empty + // set. This is safe as the permissions are always loaded before they are + // modified. + if (!s_permanentPermissionsLoaded) return; SQLiteDatabase database; diff --git a/WebKit/android/WebCoreSupport/GeolocationPermissions.h b/WebKit/android/WebCoreSupport/GeolocationPermissions.h index b0ba3ec..d6b8296 100755 --- a/WebKit/android/WebCoreSupport/GeolocationPermissions.h +++ b/WebKit/android/WebCoreSupport/GeolocationPermissions.h @@ -92,6 +92,9 @@ namespace android { static void setDatabasePath(WebCore::String path); + // Saves the permanent permissions to the DB if required. + static void maybeStorePermanentPermissions(); + private: // Records the permission state for the specified origin. void recordPermissionState(WebCore::String origin, bool allow, bool remember); @@ -113,7 +116,6 @@ namespace android { void cancelPendingRequests(WebCore::String origin); static void maybeLoadPermanentPermissions(); - static void maybeStorePermanentPermissions(); WebViewCore* m_webViewCore; WebCore::Frame* m_mainFrame; diff --git a/WebKit/android/jni/WebViewCore.cpp b/WebKit/android/jni/WebViewCore.cpp index 5e94c53..0d201b1 100644 --- a/WebKit/android/jni/WebViewCore.cpp +++ b/WebKit/android/jni/WebViewCore.cpp @@ -2937,6 +2937,15 @@ static void UpdatePluginState(JNIEnv* env, jobject obj, jint framePtr, jint node static void Pause(JNIEnv* env, jobject obj) { + // This is called for the foreground tab when the browser is put to the + // background (and also for any tab when it is put to the background of the + // browser). The browser can only be killed by the system when it is in the + // background, so saving the Geolocation permission state now ensures that + // is maintained when the browser is killed. + ChromeClient* chromeClient = GET_NATIVE_VIEW(env, obj)->mainFrame()->page()->chrome()->client(); + ChromeClientAndroid* chromeClientAndroid = static_cast<ChromeClientAndroid*>(chromeClient); + chromeClientAndroid->storeGeolocationPermissions(); + ANPEvent event; SkANP::InitEvent(&event, kLifecycle_ANPEventType); event.data.lifecycle.action = kPause_ANPLifecycleAction; |