| 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 422 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 433 CancelPendingInfoBarRequest(render_process_id, render_view_id, bridge_id); | 433 CancelPendingInfoBarRequest(render_process_id, render_view_id, bridge_id); |
| 434 } | 434 } |
| 435 | 435 |
| 436 void GeolocationPermissionContext::StartUpdatingRequested( | 436 void GeolocationPermissionContext::StartUpdatingRequested( |
| 437 int render_process_id, int render_view_id, int bridge_id, | 437 int render_process_id, int render_view_id, int bridge_id, |
| 438 const GURL& requesting_frame) { | 438 const GURL& requesting_frame) { |
| 439 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 439 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 440 // Note we cannot store the arbitrator as a member as it is not thread safe. | 440 // Note we cannot store the arbitrator as a member as it is not thread safe. |
| 441 GeolocationProvider* provider = GeolocationProvider::GetInstance(); | 441 GeolocationProvider* provider = GeolocationProvider::GetInstance(); |
| 442 | 442 |
| 443 #if defined(ENABLE_CLIENT_BASED_GEOLOCATION) |
| 444 // Client-based Geolocation uses a preemptive permission model, so permission |
| 445 // ought to have been requested and granted before the controller requests |
| 446 // requests the client to start updating. |
| 447 DCHECK(provider->HasPermissionBeenGranted()); |
| 448 #else |
| 443 // WebKit will not request permission until it has received a valid | 449 // WebKit will not request permission until it has received a valid |
| 444 // location, but the google network location provider will not give a | 450 // location, but the google network location provider will not give a |
| 445 // valid location until the user has granted permission. So we cut the Gordian | 451 // valid location until the user has granted permission. So we cut the Gordian |
| 446 // Knot by reusing the the 'start updating' request to also trigger | 452 // Knot by reusing the the 'start updating' request to also trigger |
| 447 // a 'permission request' should the provider still be awaiting permission. | 453 // a 'permission request' should the provider still be awaiting permission. |
| 448 if (!provider->HasPermissionBeenGranted()) { | 454 if (!provider->HasPermissionBeenGranted()) { |
| 449 RequestGeolocationPermission(render_process_id, render_view_id, bridge_id, | 455 RequestGeolocationPermission(render_process_id, render_view_id, bridge_id, |
| 450 requesting_frame); | 456 requesting_frame); |
| 451 } | 457 } |
| 458 #endif |
| 452 } | 459 } |
| 453 | 460 |
| 454 void GeolocationPermissionContext::StopUpdatingRequested( | 461 void GeolocationPermissionContext::StopUpdatingRequested( |
| 455 int render_process_id, int render_view_id, int bridge_id) { | 462 int render_process_id, int render_view_id, int bridge_id) { |
| 463 #if !defined(ENABLE_CLIENT_BASED_GEOLOCATION) |
| 456 CancelPendingInfoBarRequest(render_process_id, render_view_id, bridge_id); | 464 CancelPendingInfoBarRequest(render_process_id, render_view_id, bridge_id); |
| 465 #endif |
| 457 } | 466 } |
| 458 | 467 |
| 459 void GeolocationPermissionContext::NotifyPermissionSet( | 468 void GeolocationPermissionContext::NotifyPermissionSet( |
| 460 int render_process_id, int render_view_id, int bridge_id, | 469 int render_process_id, int render_view_id, int bridge_id, |
| 461 const GURL& requesting_frame, bool allowed) { | 470 const GURL& requesting_frame, bool allowed) { |
| 462 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 471 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 463 | 472 |
| 464 TabContents* tab_contents = | 473 TabContents* tab_contents = |
| 465 tab_util::GetTabContentsByID(render_process_id, render_view_id); | 474 tab_util::GetTabContentsByID(render_process_id, render_view_id); |
| 466 | 475 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 499 BrowserThread::UI, FROM_HERE, | 508 BrowserThread::UI, FROM_HERE, |
| 500 NewRunnableMethod(this, | 509 NewRunnableMethod(this, |
| 501 &GeolocationPermissionContext::CancelPendingInfoBarRequest, | 510 &GeolocationPermissionContext::CancelPendingInfoBarRequest, |
| 502 render_process_id, render_view_id, bridge_id)); | 511 render_process_id, render_view_id, bridge_id)); |
| 503 return; | 512 return; |
| 504 } | 513 } |
| 505 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 514 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 506 geolocation_infobar_queue_controller_->CancelInfoBarRequest( | 515 geolocation_infobar_queue_controller_->CancelInfoBarRequest( |
| 507 render_process_id, render_view_id, bridge_id); | 516 render_process_id, render_view_id, bridge_id); |
| 508 } | 517 } |
| OLD | NEW |