summaryrefslogtreecommitdiffstats
path: root/chrome/browser/geolocation/geolocation_permission_context_android.cc
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser/geolocation/geolocation_permission_context_android.cc')
-rw-r--r--chrome/browser/geolocation/geolocation_permission_context_android.cc41
1 files changed, 40 insertions, 1 deletions
diff --git a/chrome/browser/geolocation/geolocation_permission_context_android.cc b/chrome/browser/geolocation/geolocation_permission_context_android.cc
index 2441e59..3fd4ad1 100644
--- a/chrome/browser/geolocation/geolocation_permission_context_android.cc
+++ b/chrome/browser/geolocation/geolocation_permission_context_android.cc
@@ -4,16 +4,22 @@
#include "chrome/browser/geolocation/geolocation_permission_context_android.h"
+#include <vector>
+
+#include "base/bind.h"
#include "chrome/browser/android/location_settings.h"
#include "chrome/browser/android/location_settings_impl.h"
#include "chrome/browser/permissions/permission_request_id.h"
+#include "chrome/browser/permissions/permission_update_infobar_delegate_android.h"
+#include "content/public/browser/browser_thread.h"
#include "content/public/browser/web_contents.h"
#include "url/gurl.h"
GeolocationPermissionContextAndroid::
GeolocationPermissionContextAndroid(Profile* profile)
: GeolocationPermissionContext(profile),
- location_settings_(new LocationSettingsImpl()) {
+ location_settings_(new LocationSettingsImpl()),
+ weak_factory_(this) {
}
GeolocationPermissionContextAndroid::~GeolocationPermissionContextAndroid() {
@@ -32,10 +38,43 @@ void GeolocationPermissionContextAndroid::RequestPermission(
return;
}
+ GURL embedding_origin = web_contents->GetLastCommittedURL().GetOrigin();
+ ContentSetting content_setting =
+ GeolocationPermissionContext::GetPermissionStatus(requesting_frame_origin,
+ embedding_origin);
+ std::vector<ContentSettingsType> content_settings_types;
+ content_settings_types.push_back(CONTENT_SETTINGS_TYPE_GEOLOCATION);
+ if (content_setting == CONTENT_SETTING_ALLOW &&
+ PermissionUpdateInfoBarDelegate::ShouldShowPermissionInfobar(
+ web_contents, content_settings_types)) {
+ PermissionUpdateInfoBarDelegate::Create(
+ web_contents, content_settings_types,
+ base::Bind(
+ &GeolocationPermissionContextAndroid
+ ::HandleUpdateAndroidPermissions,
+ weak_factory_.GetWeakPtr(), id, requesting_frame_origin,
+ embedding_origin, callback));
+ return;
+ }
+
GeolocationPermissionContext::RequestPermission(
web_contents, id, requesting_frame_origin, user_gesture, callback);
}
+void GeolocationPermissionContextAndroid::HandleUpdateAndroidPermissions(
+ const PermissionRequestID& id,
+ const GURL& requesting_frame_origin,
+ const GURL& embedding_origin,
+ const BrowserPermissionCallback& callback,
+ bool permissions_updated) {
+ DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
+ ContentSetting new_setting = permissions_updated
+ ? CONTENT_SETTING_ALLOW : CONTENT_SETTING_BLOCK;
+
+ NotifyPermissionSet(id, requesting_frame_origin, embedding_origin, callback,
+ false /* persist */, new_setting);
+}
+
void GeolocationPermissionContextAndroid::SetLocationSettingsForTesting(
scoped_ptr<LocationSettings> settings) {
location_settings_ = settings.Pass();