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/chrome_geolocation_permission_context.h" | 5 #include "chrome/browser/geolocation/chrome_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/content_settings/tab_specific_content_settings.h" | 12 #include "chrome/browser/content_settings/tab_specific_content_settings.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/google/google_util.h" | 15 #include "chrome/browser/google/google_util.h" |
16 #include "chrome/browser/prefs/pref_service.h" | 16 #include "chrome/browser/prefs/pref_service.h" |
17 #include "chrome/browser/profiles/profile.h" | 17 #include "chrome/browser/profiles/profile.h" |
18 #include "chrome/browser/tab_contents/confirm_infobar_delegate.h" | 18 #include "chrome/browser/tab_contents/confirm_infobar_delegate.h" |
19 #include "chrome/browser/tab_contents/tab_util.h" | 19 #include "chrome/browser/tab_contents/tab_util.h" |
20 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 20 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
21 #include "chrome/common/extensions/extension.h" | 21 #include "chrome/common/extensions/extension.h" |
22 #include "chrome/common/pref_names.h" | 22 #include "chrome/common/pref_names.h" |
23 #include "content/browser/browser_thread.h" | 23 #include "content/browser/browser_thread.h" |
24 #include "content/browser/geolocation/geolocation_provider.h" | 24 #include "content/browser/geolocation/geolocation_provider.h" |
25 #include "content/browser/renderer_host/render_process_host.h" | 25 #include "content/browser/renderer_host/render_view_host.h" |
26 #include "content/common/content_notification_types.h" | 26 #include "content/common/content_notification_types.h" |
27 #include "content/common/notification_registrar.h" | 27 #include "content/common/notification_registrar.h" |
28 #include "content/common/notification_source.h" | 28 #include "content/common/notification_source.h" |
29 #include "grit/generated_resources.h" | 29 #include "grit/generated_resources.h" |
30 #include "grit/locale_settings.h" | 30 #include "grit/locale_settings.h" |
31 #include "grit/theme_resources.h" | 31 #include "grit/theme_resources.h" |
32 #include "grit/theme_resources_standard.h" | 32 #include "grit/theme_resources_standard.h" |
33 #include "net/base/net_util.h" | 33 #include "net/base/net_util.h" |
34 #include "ui/base/l10n/l10n_util.h" | 34 #include "ui/base/l10n/l10n_util.h" |
35 #include "ui/base/resource/resource_bundle.h" | 35 #include "ui/base/resource/resource_bundle.h" |
(...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
512 return; | 512 return; |
513 } | 513 } |
514 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 514 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
515 | 515 |
516 ExtensionService* extensions = profile_->GetExtensionService(); | 516 ExtensionService* extensions = profile_->GetExtensionService(); |
517 if (extensions) { | 517 if (extensions) { |
518 const Extension* ext = extensions->GetExtensionByURL(requesting_frame); | 518 const Extension* ext = extensions->GetExtensionByURL(requesting_frame); |
519 if (!ext) | 519 if (!ext) |
520 ext = extensions->GetExtensionByWebExtent(requesting_frame); | 520 ext = extensions->GetExtensionByWebExtent(requesting_frame); |
521 if (ext && ext->HasAPIPermission(ExtensionAPIPermission::kGeolocation)) { | 521 if (ext && ext->HasAPIPermission(ExtensionAPIPermission::kGeolocation)) { |
522 ExtensionProcessManager* epm = profile_->GetExtensionProcessManager(); | 522 // Make sure this matches the current extension. |
523 RenderProcessHost* process = epm->GetExtensionProcess(requesting_frame); | 523 RenderViewHost* rvh = RenderViewHost::FromID(render_process_id, |
524 if (process && process->id() == render_process_id) { | 524 render_view_id); |
525 NotifyPermissionSet(render_process_id, render_view_id, bridge_id, | 525 if (rvh && rvh->site_instance()) { |
526 requesting_frame, true); | 526 ExtensionProcessManager* epm = profile_->GetExtensionProcessManager(); |
527 return; | 527 const Extension* current_ext = epm->GetExtensionForSiteInstance( |
| 528 rvh->site_instance()->id()); |
| 529 if (ext == current_ext) { |
| 530 NotifyPermissionSet(render_process_id, render_view_id, bridge_id, |
| 531 requesting_frame, true); |
| 532 return; |
| 533 } |
528 } | 534 } |
529 } | 535 } |
530 } | 536 } |
531 | 537 |
532 TabContents* tab_contents = | 538 TabContents* tab_contents = |
533 tab_util::GetTabContentsByID(render_process_id, render_view_id); | 539 tab_util::GetTabContentsByID(render_process_id, render_view_id); |
534 if (!tab_contents) { | 540 if (!tab_contents) { |
535 // The tab may have gone away, or the request may not be from a tab at all. | 541 // The tab may have gone away, or the request may not be from a tab at all. |
536 LOG(WARNING) << "Attempt to use geolocation tabless renderer: " | 542 LOG(WARNING) << "Attempt to use geolocation tabless renderer: " |
537 << render_process_id << "," << render_view_id << "," | 543 << render_process_id << "," << render_view_id << "," |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
615 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { | 621 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { |
616 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, NewRunnableMethod( | 622 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, NewRunnableMethod( |
617 this, &ChromeGeolocationPermissionContext::CancelPendingInfoBarRequest, | 623 this, &ChromeGeolocationPermissionContext::CancelPendingInfoBarRequest, |
618 render_process_id, render_view_id, bridge_id)); | 624 render_process_id, render_view_id, bridge_id)); |
619 return; | 625 return; |
620 } | 626 } |
621 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 627 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
622 geolocation_infobar_queue_controller_->CancelInfoBarRequest(render_process_id, | 628 geolocation_infobar_queue_controller_->CancelInfoBarRequest(render_process_id, |
623 render_view_id, bridge_id); | 629 render_view_id, bridge_id); |
624 } | 630 } |
OLD | NEW |