OLD | NEW |
---|---|
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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.h" | 5 #include "chrome/browser/geolocation/geolocation_permission_context.h" |
6 | 6 |
7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
8 #include "app/resource_bundle.h" | 8 #include "app/resource_bundle.h" |
9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
10 #include "chrome/browser/browser_thread.h" | 10 #include "chrome/browser/browser_thread.h" |
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
432 CancelPendingInfoBarRequest(render_process_id, render_view_id, bridge_id); | 432 CancelPendingInfoBarRequest(render_process_id, render_view_id, bridge_id); |
433 } | 433 } |
434 | 434 |
435 void GeolocationPermissionContext::StartUpdatingRequested( | 435 void GeolocationPermissionContext::StartUpdatingRequested( |
436 int render_process_id, int render_view_id, int bridge_id, | 436 int render_process_id, int render_view_id, int bridge_id, |
437 const GURL& requesting_frame) { | 437 const GURL& requesting_frame) { |
438 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 438 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
439 // Note we cannot store the arbitrator as a member as it is not thread safe. | 439 // Note we cannot store the arbitrator as a member as it is not thread safe. |
440 GeolocationProvider* provider = GeolocationProvider::GetInstance(); | 440 GeolocationProvider* provider = GeolocationProvider::GetInstance(); |
441 | 441 |
442 #if defined(ENABLE_CLIENT_BASED_GEOLOCATION) | |
443 // Client-based Geolocation uses a preemptive permission model, so permission | 442 // Client-based Geolocation uses a preemptive permission model, so permission |
444 // ought to have been requested and granted before the controller requests | 443 // ought to have been requested and granted before the controller requests |
445 // the client to start updating. | 444 // the client to start updating. |
446 DCHECK(provider->HasPermissionBeenGranted()); | 445 DCHECK(provider->HasPermissionBeenGranted()); |
447 #else | |
448 // WebKit will not request permission until it has received a valid | |
449 // location, but the google network location provider will not give a | |
450 // valid location until the user has granted permission. So we cut the Gordian | |
451 // Knot by reusing the the 'start updating' request to also trigger | |
452 // a 'permission request' should the provider still be awaiting permission. | |
453 if (!provider->HasPermissionBeenGranted()) { | |
454 RequestGeolocationPermission(render_process_id, render_view_id, bridge_id, | |
455 requesting_frame); | |
456 } | |
457 #endif | |
458 } | 446 } |
459 | 447 |
460 void GeolocationPermissionContext::StopUpdatingRequested( | 448 void GeolocationPermissionContext::StopUpdatingRequested( |
461 int render_process_id, int render_view_id, int bridge_id) { | 449 int render_process_id, int render_view_id, int bridge_id) { |
bulach
2011/01/05 10:12:29
in a follow up CL, you may want to entirely remove
John Knottenbelt
2011/01/05 12:01:31
Agree.
On 2011/01/05 10:12:29, bulach wrote:
| |
462 #if !defined(ENABLE_CLIENT_BASED_GEOLOCATION) | |
463 CancelPendingInfoBarRequest(render_process_id, render_view_id, bridge_id); | |
464 #endif | |
465 } | 450 } |
466 | 451 |
467 void GeolocationPermissionContext::NotifyPermissionSet( | 452 void GeolocationPermissionContext::NotifyPermissionSet( |
468 int render_process_id, int render_view_id, int bridge_id, | 453 int render_process_id, int render_view_id, int bridge_id, |
469 const GURL& requesting_frame, bool allowed) { | 454 const GURL& requesting_frame, bool allowed) { |
470 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 455 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
471 | 456 |
472 TabContents* tab_contents = | 457 TabContents* tab_contents = |
473 tab_util::GetTabContentsByID(render_process_id, render_view_id); | 458 tab_util::GetTabContentsByID(render_process_id, render_view_id); |
474 | 459 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
507 BrowserThread::UI, FROM_HERE, | 492 BrowserThread::UI, FROM_HERE, |
508 NewRunnableMethod(this, | 493 NewRunnableMethod(this, |
509 &GeolocationPermissionContext::CancelPendingInfoBarRequest, | 494 &GeolocationPermissionContext::CancelPendingInfoBarRequest, |
510 render_process_id, render_view_id, bridge_id)); | 495 render_process_id, render_view_id, bridge_id)); |
511 return; | 496 return; |
512 } | 497 } |
513 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 498 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
514 geolocation_infobar_queue_controller_->CancelInfoBarRequest( | 499 geolocation_infobar_queue_controller_->CancelInfoBarRequest( |
515 render_process_id, render_view_id, bridge_id); | 500 render_process_id, render_view_id, bridge_id); |
516 } | 501 } |
OLD | NEW |