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" |
11 #include "chrome/browser/android/location_settings.h" | 11 #include "chrome/browser/android/location_settings.h" |
12 #include "chrome/browser/android/location_settings_impl.h" | 12 #include "chrome/browser/android/location_settings_impl.h" |
| 13 #include "chrome/browser/android/search_geolocation/search_geolocation_disclosur
e_tab_helper.h" |
13 #include "chrome/browser/android/search_geolocation/search_geolocation_service.h
" | 14 #include "chrome/browser/android/search_geolocation/search_geolocation_service.h
" |
14 #include "chrome/browser/permissions/permission_request_id.h" | 15 #include "chrome/browser/permissions/permission_request_id.h" |
15 #include "chrome/browser/permissions/permission_update_infobar_delegate_android.
h" | 16 #include "chrome/browser/permissions/permission_update_infobar_delegate_android.
h" |
16 #include "chrome/browser/profiles/profile.h" | 17 #include "chrome/browser/profiles/profile.h" |
17 #include "components/infobars/core/infobar.h" | 18 #include "components/infobars/core/infobar.h" |
18 #include "content/public/browser/browser_thread.h" | 19 #include "content/public/browser/browser_thread.h" |
| 20 #include "content/public/browser/render_frame_host.h" |
19 #include "content/public/browser/web_contents.h" | 21 #include "content/public/browser/web_contents.h" |
20 #include "url/gurl.h" | 22 #include "url/gurl.h" |
21 | 23 |
22 GeolocationPermissionContextAndroid:: | 24 GeolocationPermissionContextAndroid:: |
23 GeolocationPermissionContextAndroid(Profile* profile) | 25 GeolocationPermissionContextAndroid(Profile* profile) |
24 : GeolocationPermissionContext(profile), | 26 : GeolocationPermissionContext(profile), |
25 location_settings_(new LocationSettingsImpl()), | 27 location_settings_(new LocationSettingsImpl()), |
26 permission_update_infobar_(nullptr), | 28 permission_update_infobar_(nullptr), |
27 weak_factory_(this) { | 29 weak_factory_(this) { |
28 } | 30 } |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 content::WebContents* web_contents, | 99 content::WebContents* web_contents, |
98 const PermissionRequestID& id) { | 100 const PermissionRequestID& id) { |
99 if (permission_update_infobar_) { | 101 if (permission_update_infobar_) { |
100 permission_update_infobar_->RemoveSelf(); | 102 permission_update_infobar_->RemoveSelf(); |
101 permission_update_infobar_ = nullptr; | 103 permission_update_infobar_ = nullptr; |
102 } | 104 } |
103 | 105 |
104 GeolocationPermissionContext::CancelPermissionRequest(web_contents, id); | 106 GeolocationPermissionContext::CancelPermissionRequest(web_contents, id); |
105 } | 107 } |
106 | 108 |
| 109 void GeolocationPermissionContextAndroid::NotifyPermissionSet( |
| 110 const PermissionRequestID& id, |
| 111 const GURL& requesting_origin, |
| 112 const GURL& embedding_origin, |
| 113 const BrowserPermissionCallback& callback, |
| 114 bool persist, |
| 115 ContentSetting content_setting) { |
| 116 GeolocationPermissionContext::NotifyPermissionSet(id, requesting_origin, |
| 117 embedding_origin, callback, |
| 118 persist, content_setting); |
| 119 |
| 120 // If this is the default search origin, and the DSE Geolocation setting is |
| 121 // being used, potentially show the disclosure. |
| 122 if (requesting_origin == embedding_origin) { |
| 123 content::WebContents* web_contents = |
| 124 content::WebContents::FromRenderFrameHost( |
| 125 content::RenderFrameHost::FromID(id.render_process_id(), |
| 126 id.render_frame_id())); |
| 127 SearchGeolocationDisclosureTabHelper* disclosure_helper = |
| 128 SearchGeolocationDisclosureTabHelper::FromWebContents(web_contents); |
| 129 |
| 130 // The tab helper can be null in tests. |
| 131 if (disclosure_helper) |
| 132 disclosure_helper->MaybeShowDisclosure(requesting_origin); |
| 133 } |
| 134 } |
| 135 |
107 void GeolocationPermissionContextAndroid::HandleUpdateAndroidPermissions( | 136 void GeolocationPermissionContextAndroid::HandleUpdateAndroidPermissions( |
108 const PermissionRequestID& id, | 137 const PermissionRequestID& id, |
109 const GURL& requesting_frame_origin, | 138 const GURL& requesting_frame_origin, |
110 const GURL& embedding_origin, | 139 const GURL& embedding_origin, |
111 const BrowserPermissionCallback& callback, | 140 const BrowserPermissionCallback& callback, |
112 bool permissions_updated) { | 141 bool permissions_updated) { |
113 permission_update_infobar_ = nullptr; | 142 permission_update_infobar_ = nullptr; |
114 | 143 |
115 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 144 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
116 ContentSetting new_setting = permissions_updated | 145 ContentSetting new_setting = permissions_updated |
117 ? CONTENT_SETTING_ALLOW : CONTENT_SETTING_BLOCK; | 146 ? CONTENT_SETTING_ALLOW : CONTENT_SETTING_BLOCK; |
118 | 147 |
119 NotifyPermissionSet(id, requesting_frame_origin, embedding_origin, callback, | 148 NotifyPermissionSet(id, requesting_frame_origin, embedding_origin, callback, |
120 false /* persist */, new_setting); | 149 false /* persist */, new_setting); |
121 } | 150 } |
122 | 151 |
123 void GeolocationPermissionContextAndroid::SetLocationSettingsForTesting( | 152 void GeolocationPermissionContextAndroid::SetLocationSettingsForTesting( |
124 std::unique_ptr<LocationSettings> settings) { | 153 std::unique_ptr<LocationSettings> settings) { |
125 location_settings_ = std::move(settings); | 154 location_settings_ = std::move(settings); |
126 } | 155 } |
OLD | NEW |