summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteve Block <steveblock@google.com>2009-10-07 11:37:46 -0700
committerAndroid Git Automerger <android-git-automerger@android.com>2009-10-07 11:37:46 -0700
commit1d57ff1d97b50eacef179662ea798ac776552f34 (patch)
tree0af0fb05bd376a2b60e7476ae1c1903e91ccf2a1
parent5bbc5371dd0c031e354bc4d93218e5a1f45d8278 (diff)
parente7430864058b3c222b4b0468cf8812a9a733818b (diff)
downloadexternal_webkit-1d57ff1d97b50eacef179662ea798ac776552f34.zip
external_webkit-1d57ff1d97b50eacef179662ea798ac776552f34.tar.gz
external_webkit-1d57ff1d97b50eacef179662ea798ac776552f34.tar.bz2
am e7430864: Makes sure that Geolocation permissions are saved before the browser is killed.
Merge commit 'e7430864058b3c222b4b0468cf8812a9a733818b' into eclair-mr2 * commit 'e7430864058b3c222b4b0468cf8812a9a733818b': Makes sure that Geolocation permissions are saved before the browser is killed.
-rw-r--r--WebKit/android/WebCoreSupport/ChromeClientAndroid.cpp5
-rw-r--r--WebKit/android/WebCoreSupport/ChromeClientAndroid.h1
-rwxr-xr-xWebKit/android/WebCoreSupport/GeolocationPermissions.cpp11
-rwxr-xr-xWebKit/android/WebCoreSupport/GeolocationPermissions.h4
-rw-r--r--WebKit/android/jni/WebViewCore.cpp9
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;