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) { | |
raymes
2017/01/12 05:28:14
Should we only do this if content_setting is ALLOW
benwells
2017/01/12 06:10:33
There is already logic in the TabHelper checking t
| |
123 SearchGeolocationService* search_helper = | |
124 SearchGeolocationService::Factory::GetForBrowserContext(profile()); | |
125 if (search_helper && | |
126 search_helper->UseDSEGeolocationSetting( | |
127 url::Origin(embedding_origin))) { | |
128 content::WebContents* web_contents = | |
129 content::WebContents::FromRenderFrameHost( | |
130 content::RenderFrameHost::FromID(id.render_process_id(), | |
131 id.render_frame_id())); | |
132 SearchGeolocationDisclosureTabHelper::FromWebContents(web_contents) | |
133 ->MaybeShowDisclosureForAPIUsage(requesting_origin); | |
134 } | |
135 } | |
136 } | |
137 | |
107 void GeolocationPermissionContextAndroid::HandleUpdateAndroidPermissions( | 138 void GeolocationPermissionContextAndroid::HandleUpdateAndroidPermissions( |
108 const PermissionRequestID& id, | 139 const PermissionRequestID& id, |
109 const GURL& requesting_frame_origin, | 140 const GURL& requesting_frame_origin, |
110 const GURL& embedding_origin, | 141 const GURL& embedding_origin, |
111 const BrowserPermissionCallback& callback, | 142 const BrowserPermissionCallback& callback, |
112 bool permissions_updated) { | 143 bool permissions_updated) { |
113 permission_update_infobar_ = nullptr; | 144 permission_update_infobar_ = nullptr; |
114 | 145 |
115 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 146 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
116 ContentSetting new_setting = permissions_updated | 147 ContentSetting new_setting = permissions_updated |
117 ? CONTENT_SETTING_ALLOW : CONTENT_SETTING_BLOCK; | 148 ? CONTENT_SETTING_ALLOW : CONTENT_SETTING_BLOCK; |
118 | 149 |
119 NotifyPermissionSet(id, requesting_frame_origin, embedding_origin, callback, | 150 NotifyPermissionSet(id, requesting_frame_origin, embedding_origin, callback, |
120 false /* persist */, new_setting); | 151 false /* persist */, new_setting); |
121 } | 152 } |
122 | 153 |
123 void GeolocationPermissionContextAndroid::SetLocationSettingsForTesting( | 154 void GeolocationPermissionContextAndroid::SetLocationSettingsForTesting( |
124 std::unique_ptr<LocationSettings> settings) { | 155 std::unique_ptr<LocationSettings> settings) { |
125 location_settings_ = std::move(settings); | 156 location_settings_ = std::move(settings); |
126 } | 157 } |
OLD | NEW |