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 |
(...skipping 17 matching lines...) Expand all Loading... |
28 #include "content/browser/tab_contents/tab_contents.h" | 28 #include "content/browser/tab_contents/tab_contents.h" |
29 #include "content/public/browser/browser_thread.h" | 29 #include "content/public/browser/browser_thread.h" |
30 #include "content/public/browser/notification_registrar.h" | 30 #include "content/public/browser/notification_registrar.h" |
31 #include "content/public/browser/notification_source.h" | 31 #include "content/public/browser/notification_source.h" |
32 #include "content/public/browser/notification_types.h" | 32 #include "content/public/browser/notification_types.h" |
33 #include "grit/generated_resources.h" | 33 #include "grit/generated_resources.h" |
34 #include "grit/locale_settings.h" | 34 #include "grit/locale_settings.h" |
35 #include "grit/theme_resources.h" | 35 #include "grit/theme_resources.h" |
36 #include "grit/theme_resources_standard.h" | 36 #include "grit/theme_resources_standard.h" |
37 #include "net/base/net_util.h" | 37 #include "net/base/net_util.h" |
| 38 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h" |
38 #include "ui/base/l10n/l10n_util.h" | 39 #include "ui/base/l10n/l10n_util.h" |
39 #include "ui/base/resource/resource_bundle.h" | 40 #include "ui/base/resource/resource_bundle.h" |
40 | 41 |
41 using content::BrowserThread; | 42 using content::BrowserThread; |
| 43 using WebKit::WebSecurityOrigin; |
42 | 44 |
43 // GeolocationInfoBarQueueController ------------------------------------------ | 45 // GeolocationInfoBarQueueController ------------------------------------------ |
44 | 46 |
45 // This class controls the geolocation infobar queue per profile, and it's an | 47 // This class controls the geolocation infobar queue per profile, and it's an |
46 // internal class to GeolocationPermissionContext. | 48 // internal class to GeolocationPermissionContext. |
47 // An alternate approach would be to have this queue per tab, and use | 49 // An alternate approach would be to have this queue per tab, and use |
48 // notifications to broadcast when permission is set / listen to notification to | 50 // notifications to broadcast when permission is set / listen to notification to |
49 // cancel pending requests. This may be specially useful if there are other | 51 // cancel pending requests. This may be specially useful if there are other |
50 // things listening for such notifications. | 52 // things listening for such notifications. |
51 // For the time being this class is self-contained and it doesn't seem pulling | 53 // For the time being this class is self-contained and it doesn't seem pulling |
(...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
544 BrowserThread::PostTask( | 546 BrowserThread::PostTask( |
545 BrowserThread::UI, FROM_HERE, | 547 BrowserThread::UI, FROM_HERE, |
546 base::Bind( | 548 base::Bind( |
547 &ChromeGeolocationPermissionContext::RequestGeolocationPermission, | 549 &ChromeGeolocationPermissionContext::RequestGeolocationPermission, |
548 this, render_process_id, render_view_id, bridge_id, | 550 this, render_process_id, render_view_id, bridge_id, |
549 requesting_frame, callback)); | 551 requesting_frame, callback)); |
550 return; | 552 return; |
551 } | 553 } |
552 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 554 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
553 | 555 |
554 ExtensionService* extensions = profile_->GetExtensionService(); | 556 ExtensionService* extension_service = profile_->GetExtensionService(); |
555 if (extensions) { | 557 if (extension_service) { |
556 const Extension* ext = extensions->GetExtensionByURL(requesting_frame); | 558 const Extension* extension = |
557 if (!ext) | 559 extension_service->extensions()->GetExtensionOrAppByURL( |
558 ext = extensions->GetExtensionByWebExtent(requesting_frame); | 560 ExtensionURLInfo( |
559 if (ext && ext->HasAPIPermission(ExtensionAPIPermission::kGeolocation)) { | 561 WebSecurityOrigin::createFromString( |
| 562 UTF8ToUTF16(requesting_frame.spec())), |
| 563 requesting_frame)); |
| 564 if (extension && |
| 565 extension->HasAPIPermission(ExtensionAPIPermission::kGeolocation)) { |
560 // Make sure the extension is in the calling process. | 566 // Make sure the extension is in the calling process. |
561 if (extensions->process_map()->Contains(ext->id(), render_process_id)) { | 567 if (extension_service->process_map()->Contains( |
| 568 extension->id(), render_process_id)) { |
562 NotifyPermissionSet(render_process_id, render_view_id, bridge_id, | 569 NotifyPermissionSet(render_process_id, render_view_id, bridge_id, |
563 requesting_frame, callback, true); | 570 requesting_frame, callback, true); |
564 return; | 571 return; |
565 } | 572 } |
566 } | 573 } |
567 } | 574 } |
568 | 575 |
569 TabContents* tab_contents = | 576 TabContents* tab_contents = |
570 tab_util::GetTabContentsByID(render_process_id, render_view_id); | 577 tab_util::GetTabContentsByID(render_process_id, render_view_id); |
571 if (!tab_contents || | 578 if (!tab_contents || |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
662 BrowserThread::UI, FROM_HERE, | 669 BrowserThread::UI, FROM_HERE, |
663 base::Bind( | 670 base::Bind( |
664 &ChromeGeolocationPermissionContext::CancelPendingInfoBarRequest, | 671 &ChromeGeolocationPermissionContext::CancelPendingInfoBarRequest, |
665 this, render_process_id, render_view_id, bridge_id)); | 672 this, render_process_id, render_view_id, bridge_id)); |
666 return; | 673 return; |
667 } | 674 } |
668 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 675 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
669 geolocation_infobar_queue_controller_->CancelInfoBarRequest(render_process_id, | 676 geolocation_infobar_queue_controller_->CancelInfoBarRequest(render_process_id, |
670 render_view_id, bridge_id); | 677 render_view_id, bridge_id); |
671 } | 678 } |
OLD | NEW |