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