diff options
| author | Steve Block <steveblock@google.com> | 2009-10-07 13:22:07 +0100 |
|---|---|---|
| committer | Steve Block <steveblock@google.com> | 2009-10-07 16:35:16 +0100 |
| commit | e7430864058b3c222b4b0468cf8812a9a733818b (patch) | |
| tree | 145b749eae771ac8b58278976c0091219cf1bf74 /WebKit/android/WebCoreSupport | |
| parent | a7280594a8eac3503fe491d2ea02ce684fdf8744 (diff) | |
| download | external_webkit-e7430864058b3c222b4b0468cf8812a9a733818b.zip external_webkit-e7430864058b3c222b4b0468cf8812a9a733818b.tar.gz external_webkit-e7430864058b3c222b4b0468cf8812a9a733818b.tar.bz2 | |
Makes sure that Geolocation permissions are saved before the browser is killed.
This is a fix for http://b/issue?id=2167364
Change-Id: I92a1a6831eb254b62593beaf7cb77c8e1f41945c
Diffstat (limited to 'WebKit/android/WebCoreSupport')
4 files changed, 14 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; |
