| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/geolocation/geolocation_permission_context_android.h" | 5 #include "chrome/browser/geolocation/geolocation_permission_context_android.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 weak_factory_(this) { | 25 weak_factory_(this) { |
| 26 } | 26 } |
| 27 | 27 |
| 28 GeolocationPermissionContextAndroid::~GeolocationPermissionContextAndroid() { | 28 GeolocationPermissionContextAndroid::~GeolocationPermissionContextAndroid() { |
| 29 } | 29 } |
| 30 | 30 |
| 31 void GeolocationPermissionContextAndroid::RequestPermission( | 31 void GeolocationPermissionContextAndroid::RequestPermission( |
| 32 content::WebContents* web_contents, | 32 content::WebContents* web_contents, |
| 33 const PermissionRequestID& id, | 33 const PermissionRequestID& id, |
| 34 const GURL& requesting_frame_origin, | 34 const GURL& requesting_frame_origin, |
| 35 bool user_gesture, |
| 35 const BrowserPermissionCallback& callback) { | 36 const BrowserPermissionCallback& callback) { |
| 36 if (!location_settings_->CanSitesRequestLocationPermission(web_contents)) { | 37 if (!location_settings_->CanSitesRequestLocationPermission(web_contents)) { |
| 37 PermissionDecided(id, requesting_frame_origin, | 38 PermissionDecided(id, requesting_frame_origin, |
| 38 web_contents->GetLastCommittedURL().GetOrigin(), | 39 web_contents->GetLastCommittedURL().GetOrigin(), |
| 39 callback, false /* persist */, CONTENT_SETTING_BLOCK); | 40 callback, false /* persist */, CONTENT_SETTING_BLOCK); |
| 40 return; | 41 return; |
| 41 } | 42 } |
| 42 | 43 |
| 43 GURL embedding_origin = web_contents->GetLastCommittedURL().GetOrigin(); | 44 GURL embedding_origin = web_contents->GetLastCommittedURL().GetOrigin(); |
| 44 ContentSetting content_setting = | 45 ContentSetting content_setting = |
| 45 GeolocationPermissionContext::GetPermissionStatus(requesting_frame_origin, | 46 GeolocationPermissionContext::GetPermissionStatus(requesting_frame_origin, |
| 46 embedding_origin); | 47 embedding_origin); |
| 47 std::vector<ContentSettingsType> content_settings_types; | 48 std::vector<ContentSettingsType> content_settings_types; |
| 48 content_settings_types.push_back(CONTENT_SETTINGS_TYPE_GEOLOCATION); | 49 content_settings_types.push_back(CONTENT_SETTINGS_TYPE_GEOLOCATION); |
| 49 if (content_setting == CONTENT_SETTING_ALLOW && | 50 if (content_setting == CONTENT_SETTING_ALLOW && |
| 50 PermissionUpdateInfoBarDelegate::ShouldShowPermissionInfobar( | 51 PermissionUpdateInfoBarDelegate::ShouldShowPermissionInfobar( |
| 51 web_contents, content_settings_types)) { | 52 web_contents, content_settings_types)) { |
| 52 permission_update_infobar_ = PermissionUpdateInfoBarDelegate::Create( | 53 permission_update_infobar_ = PermissionUpdateInfoBarDelegate::Create( |
| 53 web_contents, content_settings_types, | 54 web_contents, content_settings_types, |
| 54 base::Bind( | 55 base::Bind( |
| 55 &GeolocationPermissionContextAndroid | 56 &GeolocationPermissionContextAndroid |
| 56 ::HandleUpdateAndroidPermissions, | 57 ::HandleUpdateAndroidPermissions, |
| 57 weak_factory_.GetWeakPtr(), id, requesting_frame_origin, | 58 weak_factory_.GetWeakPtr(), id, requesting_frame_origin, |
| 58 embedding_origin, callback)); | 59 embedding_origin, callback)); |
| 59 | 60 |
| 60 return; | 61 return; |
| 61 } | 62 } |
| 62 | 63 |
| 63 GeolocationPermissionContext::RequestPermission( | 64 GeolocationPermissionContext::RequestPermission( |
| 64 web_contents, id, requesting_frame_origin, callback); | 65 web_contents, id, requesting_frame_origin, user_gesture, callback); |
| 65 } | 66 } |
| 66 | 67 |
| 67 void GeolocationPermissionContextAndroid::CancelPermissionRequest( | 68 void GeolocationPermissionContextAndroid::CancelPermissionRequest( |
| 68 content::WebContents* web_contents, | 69 content::WebContents* web_contents, |
| 69 const PermissionRequestID& id) { | 70 const PermissionRequestID& id) { |
| 70 if (permission_update_infobar_) { | 71 if (permission_update_infobar_) { |
| 71 permission_update_infobar_->RemoveSelf(); | 72 permission_update_infobar_->RemoveSelf(); |
| 72 permission_update_infobar_ = nullptr; | 73 permission_update_infobar_ = nullptr; |
| 73 } | 74 } |
| 74 | 75 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 88 ? CONTENT_SETTING_ALLOW : CONTENT_SETTING_BLOCK; | 89 ? CONTENT_SETTING_ALLOW : CONTENT_SETTING_BLOCK; |
| 89 | 90 |
| 90 NotifyPermissionSet(id, requesting_frame_origin, embedding_origin, callback, | 91 NotifyPermissionSet(id, requesting_frame_origin, embedding_origin, callback, |
| 91 false /* persist */, new_setting); | 92 false /* persist */, new_setting); |
| 92 } | 93 } |
| 93 | 94 |
| 94 void GeolocationPermissionContextAndroid::SetLocationSettingsForTesting( | 95 void GeolocationPermissionContextAndroid::SetLocationSettingsForTesting( |
| 95 std::unique_ptr<LocationSettings> settings) { | 96 std::unique_ptr<LocationSettings> settings) { |
| 96 location_settings_ = std::move(settings); | 97 location_settings_ = std::move(settings); |
| 97 } | 98 } |
| OLD | NEW |