| 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" |
| 11 #include "chrome/browser/extensions/extension_service.h" | 11 #include "chrome/browser/extensions/extension_service.h" |
| 12 #include "chrome/browser/geolocation/geolocation_content_settings_map.h" | 12 #include "chrome/browser/geolocation/geolocation_content_settings_map.h" |
| 13 #include "chrome/browser/geolocation/geolocation_dispatcher_host_old.h" |
| 13 #include "chrome/browser/geolocation/geolocation_provider.h" | 14 #include "chrome/browser/geolocation/geolocation_provider.h" |
| 14 #include "chrome/browser/google/google_util.h" | 15 #include "chrome/browser/google/google_util.h" |
| 15 #include "chrome/browser/prefs/pref_service.h" | 16 #include "chrome/browser/prefs/pref_service.h" |
| 16 #include "chrome/browser/profiles/profile.h" | 17 #include "chrome/browser/profiles/profile.h" |
| 17 #include "chrome/browser/renderer_host/render_process_host.h" | 18 #include "chrome/browser/renderer_host/render_process_host.h" |
| 18 #include "chrome/browser/renderer_host/render_view_host.h" | 19 #include "chrome/browser/renderer_host/render_view_host.h" |
| 19 #include "chrome/browser/renderer_host/render_view_host_notification_task.h" | 20 #include "chrome/browser/renderer_host/render_view_host_notification_task.h" |
| 20 #include "chrome/browser/tab_contents/infobar_delegate.h" | 21 #include "chrome/browser/tab_contents/infobar_delegate.h" |
| 21 #include "chrome/browser/tab_contents/tab_contents.h" | 22 #include "chrome/browser/tab_contents/tab_contents.h" |
| 22 #include "chrome/browser/tab_contents/tab_util.h" | 23 #include "chrome/browser/tab_contents/tab_util.h" |
| (...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 432 CancelPendingInfoBarRequest(render_process_id, render_view_id, bridge_id); | 433 CancelPendingInfoBarRequest(render_process_id, render_view_id, bridge_id); |
| 433 } | 434 } |
| 434 | 435 |
| 435 void GeolocationPermissionContext::StartUpdatingRequested( | 436 void GeolocationPermissionContext::StartUpdatingRequested( |
| 436 int render_process_id, int render_view_id, int bridge_id, | 437 int render_process_id, int render_view_id, int bridge_id, |
| 437 const GURL& requesting_frame) { | 438 const GURL& requesting_frame) { |
| 438 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 439 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 439 // 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. |
| 440 GeolocationProvider* provider = GeolocationProvider::GetInstance(); | 441 GeolocationProvider* provider = GeolocationProvider::GetInstance(); |
| 441 | 442 |
| 442 #if defined(ENABLE_CLIENT_BASED_GEOLOCATION) | |
| 443 // Client-based Geolocation uses a preemptive permission model, so permission | |
| 444 // ought to have been requested and granted before the controller requests | |
| 445 // the client to start updating. | |
| 446 DCHECK(provider->HasPermissionBeenGranted()); | |
| 447 #else | |
| 448 // WebKit will not request permission until it has received a valid | 443 // WebKit will not request permission until it has received a valid |
| 449 // location, but the google network location provider will not give a | 444 // 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 | 445 // 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 | 446 // Knot by reusing the the 'start updating' request to also trigger |
| 452 // a 'permission request' should the provider still be awaiting permission. | 447 // a 'permission request' should the provider still be awaiting permission. |
| 453 if (!provider->HasPermissionBeenGranted()) { | 448 if (!provider->HasPermissionBeenGranted()) { |
| 454 RequestGeolocationPermission(render_process_id, render_view_id, bridge_id, | 449 RequestGeolocationPermission(render_process_id, render_view_id, bridge_id, |
| 455 requesting_frame); | 450 requesting_frame); |
| 456 } | 451 } |
| 457 #endif | |
| 458 } | 452 } |
| 459 | 453 |
| 460 void GeolocationPermissionContext::StopUpdatingRequested( | 454 void GeolocationPermissionContext::StopUpdatingRequested( |
| 461 int render_process_id, int render_view_id, int bridge_id) { | 455 int render_process_id, int render_view_id, int bridge_id) { |
| 462 #if !defined(ENABLE_CLIENT_BASED_GEOLOCATION) | |
| 463 CancelPendingInfoBarRequest(render_process_id, render_view_id, bridge_id); | 456 CancelPendingInfoBarRequest(render_process_id, render_view_id, bridge_id); |
| 464 #endif | |
| 465 } | 457 } |
| 466 | 458 |
| 467 void GeolocationPermissionContext::NotifyPermissionSet( | 459 void GeolocationPermissionContext::NotifyPermissionSet( |
| 468 int render_process_id, int render_view_id, int bridge_id, | 460 int render_process_id, int render_view_id, int bridge_id, |
| 469 const GURL& requesting_frame, bool allowed) { | 461 const GURL& requesting_frame, bool allowed) { |
| 470 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 462 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 471 | 463 |
| 472 TabContents* tab_contents = | 464 TabContents* tab_contents = |
| 473 tab_util::GetTabContentsByID(render_process_id, render_view_id); | 465 tab_util::GetTabContentsByID(render_process_id, render_view_id); |
| 474 | 466 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 507 BrowserThread::UI, FROM_HERE, | 499 BrowserThread::UI, FROM_HERE, |
| 508 NewRunnableMethod(this, | 500 NewRunnableMethod(this, |
| 509 &GeolocationPermissionContext::CancelPendingInfoBarRequest, | 501 &GeolocationPermissionContext::CancelPendingInfoBarRequest, |
| 510 render_process_id, render_view_id, bridge_id)); | 502 render_process_id, render_view_id, bridge_id)); |
| 511 return; | 503 return; |
| 512 } | 504 } |
| 513 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 505 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 514 geolocation_infobar_queue_controller_->CancelInfoBarRequest( | 506 geolocation_infobar_queue_controller_->CancelInfoBarRequest( |
| 515 render_process_id, render_view_id, bridge_id); | 507 render_process_id, render_view_id, bridge_id); |
| 516 } | 508 } |
| OLD | NEW |