Index: chrome/browser/geolocation/geolocation_permission_context_android.cc |
diff --git a/chrome/browser/geolocation/geolocation_permission_context_android.cc b/chrome/browser/geolocation/geolocation_permission_context_android.cc |
index 51f1f1b82f79550e0c762a7815d46200281611a6..4b15767ea23e3de28c4e4fe765bff58702f92c68 100644 |
--- a/chrome/browser/geolocation/geolocation_permission_context_android.cc |
+++ b/chrome/browser/geolocation/geolocation_permission_context_android.cc |
@@ -10,6 +10,7 @@ |
#include "base/bind.h" |
#include "chrome/browser/android/location_settings.h" |
#include "chrome/browser/android/location_settings_impl.h" |
+#include "chrome/browser/android/search_geolocation/search_geolocation_disclosure_tab_helper.h" |
#include "chrome/browser/android/search_geolocation/search_geolocation_service.h" |
#include "chrome/browser/permissions/permission_request_id.h" |
#include "chrome/browser/permissions/permission_update_infobar_delegate_android.h" |
@@ -62,7 +63,7 @@ void GeolocationPermissionContextAndroid::RequestPermission( |
bool user_gesture, |
const BrowserPermissionCallback& callback) { |
if (!location_settings_->CanSitesRequestLocationPermission(web_contents)) { |
- PermissionDecided(id, requesting_frame_origin, |
+ PermissionDecided(web_contents, id, requesting_frame_origin, |
web_contents->GetLastCommittedURL().GetOrigin(), |
user_gesture, callback, false /* persist */, |
CONTENT_SETTING_BLOCK); |
@@ -80,11 +81,10 @@ void GeolocationPermissionContextAndroid::RequestPermission( |
web_contents, content_settings_types)) { |
permission_update_infobar_ = PermissionUpdateInfoBarDelegate::Create( |
web_contents, content_settings_types, |
- base::Bind( |
- &GeolocationPermissionContextAndroid |
- ::HandleUpdateAndroidPermissions, |
- weak_factory_.GetWeakPtr(), id, requesting_frame_origin, |
- embedding_origin, callback)); |
+ base::Bind(&GeolocationPermissionContextAndroid:: |
+ HandleUpdateAndroidPermissions, |
+ weak_factory_.GetWeakPtr(), web_contents, id, |
+ requesting_frame_origin, embedding_origin, callback)); |
return; |
} |
@@ -104,7 +104,38 @@ void GeolocationPermissionContextAndroid::CancelPermissionRequest( |
GeolocationPermissionContext::CancelPermissionRequest(web_contents, id); |
} |
+void GeolocationPermissionContextAndroid::NotifyPermissionSet( |
+ content::WebContents* web_contents, |
+ const PermissionRequestID& id, |
+ const GURL& requesting_origin, |
+ const GURL& embedding_origin, |
+ const BrowserPermissionCallback& callback, |
+ bool persist, |
+ ContentSetting content_setting) { |
+ GeolocationPermissionContext::NotifyPermissionSet( |
+ web_contents, id, requesting_origin, embedding_origin, callback, persist, |
raymes
2017/01/12 00:17:12
You can actually get at the web_contents from Perm
benwells
2017/01/12 01:04:17
Ah ... that would make this change a lot simpler.
raymes
2017/01/12 01:41:17
I would lean toward not passing it and just grabbi
benwells
2017/01/12 04:13:49
Done.
|
+ content_setting); |
+ |
+ // If this is the default search origin, and the DSE Geolocation setting is |
+ // being used, potentially show the disclosure. |
+ if (requesting_origin == embedding_origin) { |
+ // Consult the DSE Geolocation setting. Note that this only needs to be |
+ // consulted when the content setting is ASK. In the other cases (ALLOW or |
+ // BLOCK) checking the setting is redundant, as the setting is kept |
+ // consistent with the content setting. |
raymes
2017/01/12 00:17:12
Is this comment needed/accurate?
benwells
2017/01/12 04:13:49
Done.
|
+ SearchGeolocationService* search_helper = |
+ SearchGeolocationService::Factory::GetForBrowserContext(profile()); |
+ if (search_helper && |
+ search_helper->UseDSEGeolocationSetting( |
+ url::Origin(embedding_origin))) { |
+ SearchGeolocationDisclosureTabHelper::FromWebContents(web_contents) |
+ ->MaybeShowDisclosureForAPIUsage(requesting_origin); |
+ } |
+ } |
+} |
+ |
void GeolocationPermissionContextAndroid::HandleUpdateAndroidPermissions( |
+ content::WebContents* web_contents, |
const PermissionRequestID& id, |
const GURL& requesting_frame_origin, |
const GURL& embedding_origin, |
@@ -116,8 +147,9 @@ void GeolocationPermissionContextAndroid::HandleUpdateAndroidPermissions( |
ContentSetting new_setting = permissions_updated |
? CONTENT_SETTING_ALLOW : CONTENT_SETTING_BLOCK; |
- NotifyPermissionSet(id, requesting_frame_origin, embedding_origin, callback, |
- false /* persist */, new_setting); |
+ NotifyPermissionSet(web_contents, id, requesting_frame_origin, |
+ embedding_origin, callback, false /* persist */, |
+ new_setting); |
} |
void GeolocationPermissionContextAndroid::SetLocationSettingsForTesting( |