Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(26)

Side by Side Diff: chrome/browser/geolocation/chrome_geolocation_permission_context.cc

Issue 23345004: Fix Android strict-mode violation in GeoLocation info bar. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address comments / fix tests Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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/chrome_geolocation_permission_context.h" 5 #include "chrome/browser/geolocation/chrome_geolocation_permission_context.h"
6 6
7 #include <functional> 7 #include <functional>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 GURL embedder = web_contents->GetLastCommittedURL().GetOrigin(); 182 GURL embedder = web_contents->GetLastCommittedURL().GetOrigin();
183 if (!requesting_frame_origin.is_valid() || !embedder.is_valid()) { 183 if (!requesting_frame_origin.is_valid() || !embedder.is_valid()) {
184 LOG(WARNING) << "Attempt to use geolocation from an invalid URL: " 184 LOG(WARNING) << "Attempt to use geolocation from an invalid URL: "
185 << requesting_frame_origin << "," << embedder 185 << requesting_frame_origin << "," << embedder
186 << " (geolocation is not supported in popups)"; 186 << " (geolocation is not supported in popups)";
187 NotifyPermissionSet(id, requesting_frame_origin, callback, false); 187 NotifyPermissionSet(id, requesting_frame_origin, callback, false);
188 return; 188 return;
189 } 189 }
190 190
191 DecidePermission(web_contents, id, requesting_frame_origin, 191 DecidePermission(web_contents, id, requesting_frame_origin,
192 embedder, callback); 192 embedder, "", callback);
193 } 193 }
194 194
195 void ChromeGeolocationPermissionContext::CancelGeolocationPermissionRequest( 195 void ChromeGeolocationPermissionContext::CancelGeolocationPermissionRequest(
196 int render_process_id, 196 int render_process_id,
197 int render_view_id, 197 int render_view_id,
198 int bridge_id, 198 int bridge_id,
199 const GURL& requesting_frame) { 199 const GURL& requesting_frame) {
200 CancelPendingInfobarRequest(PermissionRequestID( 200 CancelPendingInfobarRequest(PermissionRequestID(
201 render_process_id, render_view_id, bridge_id, 0)); 201 render_process_id, render_view_id, bridge_id, 0));
202 } 202 }
203 203
204 void ChromeGeolocationPermissionContext::DecidePermission( 204 void ChromeGeolocationPermissionContext::DecidePermission(
205 content::WebContents* web_contents, 205 content::WebContents* web_contents,
206 const PermissionRequestID& id, 206 const PermissionRequestID& id,
207 const GURL& requesting_frame, 207 const GURL& requesting_frame,
208 const GURL& embedder, 208 const GURL& embedder,
209 const std::string& accept_button_label,
209 base::Callback<void(bool)> callback) { 210 base::Callback<void(bool)> callback) {
210 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 211 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
211 212
212 ContentSetting content_setting = 213 ContentSetting content_setting =
213 profile_->GetHostContentSettingsMap()->GetContentSetting( 214 profile_->GetHostContentSettingsMap()->GetContentSetting(
214 requesting_frame, embedder, CONTENT_SETTINGS_TYPE_GEOLOCATION, 215 requesting_frame, embedder, CONTENT_SETTINGS_TYPE_GEOLOCATION,
215 std::string()); 216 std::string());
216 switch (content_setting) { 217 switch (content_setting) {
217 case CONTENT_SETTING_BLOCK: 218 case CONTENT_SETTING_BLOCK:
218 PermissionDecided(id, requesting_frame, embedder, callback, false); 219 PermissionDecided(id, requesting_frame, embedder, callback, false);
219 break; 220 break;
220 case CONTENT_SETTING_ALLOW: 221 case CONTENT_SETTING_ALLOW:
221 PermissionDecided(id, requesting_frame, embedder, callback, true); 222 PermissionDecided(id, requesting_frame, embedder, callback, true);
222 break; 223 break;
223 default: 224 default:
224 if (PermissionBubbleManager::Enabled()) { 225 if (PermissionBubbleManager::Enabled()) {
225 PermissionBubbleManager* mgr = 226 PermissionBubbleManager* mgr =
226 PermissionBubbleManager::FromWebContents(web_contents); 227 PermissionBubbleManager::FromWebContents(web_contents);
227 mgr->AddRequest(new GeolocationPermissionRequest( 228 mgr->AddRequest(new GeolocationPermissionRequest(
228 this, id, requesting_frame, callback, 229 this, id, requesting_frame, callback,
229 profile_->GetPrefs()->GetString(prefs::kAcceptLanguages))); 230 profile_->GetPrefs()->GetString(prefs::kAcceptLanguages)));
230 } else { 231 } else {
231 // setting == ask. Prompt the user. 232 // setting == ask. Prompt the user.
232 QueueController()->CreateInfoBarRequest( 233 QueueController()->CreateInfoBarRequest(
233 id, requesting_frame, embedder, base::Bind( 234 id, requesting_frame, embedder, accept_button_label,
234 &ChromeGeolocationPermissionContext::NotifyPermissionSet, 235 base::Bind(
236 &ChromeGeolocationPermissionContext::NotifyPermissionSet,
235 base::Unretained(this), id, requesting_frame, callback)); 237 base::Unretained(this), id, requesting_frame, callback));
236 } 238 }
237 } 239 }
238 } 240 }
239 241
242 void ChromeGeolocationPermissionContext::CreateInfoBarRequest(
243 const PermissionRequestID& id,
244 const GURL& requesting_frame,
245 const GURL& embedder,
246 const std::string accept_button_label,
247 base::Callback<void(bool)> callback) {
248 QueueController()->CreateInfoBarRequest(
249 id, requesting_frame, embedder, accept_button_label, base::Bind(
250 &ChromeGeolocationPermissionContext::NotifyPermissionSet,
251 base::Unretained(this), id, requesting_frame, callback));
252 }
253
240 void ChromeGeolocationPermissionContext::ShutdownOnUIThread() { 254 void ChromeGeolocationPermissionContext::ShutdownOnUIThread() {
241 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 255 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
242 permission_queue_controller_.reset(); 256 permission_queue_controller_.reset();
243 shutting_down_ = true; 257 shutting_down_ = true;
244 } 258 }
245 259
246 void ChromeGeolocationPermissionContext::PermissionDecided( 260 void ChromeGeolocationPermissionContext::PermissionDecided(
247 const PermissionRequestID& id, 261 const PermissionRequestID& id,
248 const GURL& requesting_frame, 262 const GURL& requesting_frame,
249 const GURL& embedder, 263 const GURL& embedder,
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 this, id)); 311 this, id));
298 return; 312 return;
299 } 313 }
300 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 314 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
301 if (shutting_down_) 315 if (shutting_down_)
302 return; 316 return;
303 317
304 // TODO(gbillock): handle permission bubble cancellation. 318 // TODO(gbillock): handle permission bubble cancellation.
305 QueueController()->CancelInfoBarRequest(id); 319 QueueController()->CancelInfoBarRequest(id);
306 } 320 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698