| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "content/browser/geolocation/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 |
| 11 #include "base/utf_string_conversions.h" | 11 #include "base/utf_string_conversions.h" |
| 12 #include "chrome/browser/browser_thread.h" | 12 #include "chrome/browser/browser_thread.h" |
| 13 #include "chrome/browser/extensions/extension_service.h" | 13 #include "chrome/browser/extensions/extension_service.h" |
| 14 #include "chrome/browser/geolocation/geolocation_content_settings_map.h" | 14 #include "chrome/browser/geolocation/geolocation_content_settings_map.h" |
| 15 #include "chrome/browser/geolocation/geolocation_provider.h" | |
| 16 #include "chrome/browser/google/google_util.h" | 15 #include "chrome/browser/google/google_util.h" |
| 17 #include "chrome/browser/prefs/pref_service.h" | 16 #include "chrome/browser/prefs/pref_service.h" |
| 18 #include "chrome/browser/profiles/profile.h" | 17 #include "chrome/browser/profiles/profile.h" |
| 19 #include "chrome/browser/renderer_host/render_process_host.h" | |
| 20 #include "chrome/browser/renderer_host/render_view_host.h" | |
| 21 #include "chrome/browser/renderer_host/render_view_host_notification_task.h" | |
| 22 #include "chrome/browser/tab_contents/infobar_delegate.h" | 18 #include "chrome/browser/tab_contents/infobar_delegate.h" |
| 23 #include "chrome/browser/tab_contents/tab_contents.h" | |
| 24 #include "chrome/browser/tab_contents/tab_util.h" | 19 #include "chrome/browser/tab_contents/tab_util.h" |
| 25 #include "chrome/common/extensions/extension.h" | 20 #include "chrome/common/extensions/extension.h" |
| 26 #include "chrome/common/notification_registrar.h" | 21 #include "chrome/common/notification_registrar.h" |
| 27 #include "chrome/common/notification_source.h" | 22 #include "chrome/common/notification_source.h" |
| 28 #include "chrome/common/notification_type.h" | 23 #include "chrome/common/notification_type.h" |
| 29 #include "chrome/common/pref_names.h" | 24 #include "chrome/common/pref_names.h" |
| 30 #include "chrome/common/render_messages.h" | 25 #include "chrome/common/render_messages.h" |
| 26 #include "content/browser/geolocation/geolocation_provider.h" |
| 27 #include "content/browser/renderer_host/render_process_host.h" |
| 28 #include "content/browser/renderer_host/render_view_host.h" |
| 29 #include "content/browser/tab_contents/tab_contents.h" |
| 31 #include "grit/generated_resources.h" | 30 #include "grit/generated_resources.h" |
| 32 #include "grit/locale_settings.h" | 31 #include "grit/locale_settings.h" |
| 33 #include "grit/theme_resources.h" | 32 #include "grit/theme_resources.h" |
| 34 #include "net/base/net_util.h" | 33 #include "net/base/net_util.h" |
| 35 #include "ui/base/l10n/l10n_util.h" | 34 #include "ui/base/l10n/l10n_util.h" |
| 36 #include "ui/base/resource/resource_bundle.h" | 35 #include "ui/base/resource/resource_bundle.h" |
| 37 | 36 |
| 38 // GeolocationInfoBarQueueController ------------------------------------------ | 37 // GeolocationInfoBarQueueController ------------------------------------------ |
| 39 | 38 |
| 40 // This class controls the geolocation infobar queue per profile, and it's an | 39 // This class controls the geolocation infobar queue per profile, and it's an |
| (...skipping 547 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 588 tab_util::GetTabContentsByID(render_process_id, render_view_id); | 587 tab_util::GetTabContentsByID(render_process_id, render_view_id); |
| 589 | 588 |
| 590 // TabContents may have gone away (or not exists for extension). | 589 // TabContents may have gone away (or not exists for extension). |
| 591 if (tab_contents) { | 590 if (tab_contents) { |
| 592 TabSpecificContentSettings* content_settings = | 591 TabSpecificContentSettings* content_settings = |
| 593 tab_contents->GetTabSpecificContentSettings(); | 592 tab_contents->GetTabSpecificContentSettings(); |
| 594 content_settings->OnGeolocationPermissionSet(requesting_frame.GetOrigin(), | 593 content_settings->OnGeolocationPermissionSet(requesting_frame.GetOrigin(), |
| 595 allowed); | 594 allowed); |
| 596 } | 595 } |
| 597 | 596 |
| 598 CallRenderViewHost(render_process_id, render_view_id, &RenderViewHost::Send, | 597 RenderViewHost* r = RenderViewHost::FromID(render_process_id, render_view_id); |
| 599 new ViewMsg_Geolocation_PermissionSet(render_view_id, bridge_id, | 598 if (r) { |
| 600 allowed)); | 599 r->Send(new ViewMsg_Geolocation_PermissionSet( |
| 600 render_view_id, bridge_id, allowed)); |
| 601 } |
| 602 |
| 601 if (allowed) { | 603 if (allowed) { |
| 602 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, NewRunnableMethod( | 604 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, NewRunnableMethod( |
| 603 this, &GeolocationPermissionContext::NotifyArbitratorPermissionGranted, | 605 this, &GeolocationPermissionContext::NotifyArbitratorPermissionGranted, |
| 604 requesting_frame)); | 606 requesting_frame)); |
| 605 } | 607 } |
| 606 } | 608 } |
| 607 | 609 |
| 608 void GeolocationPermissionContext::NotifyArbitratorPermissionGranted( | 610 void GeolocationPermissionContext::NotifyArbitratorPermissionGranted( |
| 609 const GURL& requesting_frame) { | 611 const GURL& requesting_frame) { |
| 610 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 612 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 611 GeolocationProvider::GetInstance()->OnPermissionGranted(requesting_frame); | 613 GeolocationProvider::GetInstance()->OnPermissionGranted(requesting_frame); |
| 612 } | 614 } |
| 613 | 615 |
| 614 void GeolocationPermissionContext::CancelPendingInfoBarRequest( | 616 void GeolocationPermissionContext::CancelPendingInfoBarRequest( |
| 615 int render_process_id, | 617 int render_process_id, |
| 616 int render_view_id, | 618 int render_view_id, |
| 617 int bridge_id) { | 619 int bridge_id) { |
| 618 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { | 620 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { |
| 619 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, NewRunnableMethod( | 621 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, NewRunnableMethod( |
| 620 this, &GeolocationPermissionContext::CancelPendingInfoBarRequest, | 622 this, &GeolocationPermissionContext::CancelPendingInfoBarRequest, |
| 621 render_process_id, render_view_id, bridge_id)); | 623 render_process_id, render_view_id, bridge_id)); |
| 622 return; | 624 return; |
| 623 } | 625 } |
| 624 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 626 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 625 geolocation_infobar_queue_controller_->CancelInfoBarRequest(render_process_id, | 627 geolocation_infobar_queue_controller_->CancelInfoBarRequest(render_process_id, |
| 626 render_view_id, bridge_id); | 628 render_view_id, bridge_id); |
| 627 } | 629 } |
| OLD | NEW |