Chromium Code Reviews| 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 19 matching lines...) Expand all Loading... | |
| 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 "ui/base/l10n/l10n_util.h" | 38 #include "ui/base/l10n/l10n_util.h" |
| 39 #include "ui/base/resource/resource_bundle.h" | 39 #include "ui/base/resource/resource_bundle.h" |
| 40 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.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* ext_service = profile_->GetExtensionService(); |
|
Aaron Boodman
2011/12/09 16:05:20
Styleguide says to avoid abbreviations.
Yoyo Zhou
2011/12/09 19:59:09
Ok. I'll fix that - here and some other places I f
| |
| 555 if (extensions) { | 557 if (ext_service) { |
| 556 const Extension* ext = extensions->GetExtensionByURL(requesting_frame); | 558 const Extension* ext = |
| 557 if (!ext) | 559 ext_service->extensions()->GetByURL(ExtensionURLInfo( |
| 558 ext = extensions->GetExtensionByWebExtent(requesting_frame); | 560 WebSecurityOrigin::createFromString( |
|
Aaron Boodman
2011/12/09 16:05:20
Nuts. This should be an easy one to cleanup though
Yoyo Zhou
2011/12/09 19:59:09
What do you mean - using a string16/WebSecurityOri
| |
| 561 UTF8ToUTF16(requesting_frame.spec())), | |
| 562 requesting_frame)); | |
| 559 if (ext && ext->HasAPIPermission(ExtensionAPIPermission::kGeolocation)) { | 563 if (ext && ext->HasAPIPermission(ExtensionAPIPermission::kGeolocation)) { |
| 560 // Make sure the extension is in the calling process. | 564 // Make sure the extension is in the calling process. |
| 561 if (extensions->process_map()->Contains(ext->id(), render_process_id)) { | 565 if (ext_service->process_map()->Contains(ext->id(), render_process_id)) { |
| 562 NotifyPermissionSet(render_process_id, render_view_id, bridge_id, | 566 NotifyPermissionSet(render_process_id, render_view_id, bridge_id, |
| 563 requesting_frame, callback, true); | 567 requesting_frame, callback, true); |
| 564 return; | 568 return; |
| 565 } | 569 } |
| 566 } | 570 } |
| 567 } | 571 } |
| 568 | 572 |
| 569 TabContents* tab_contents = | 573 TabContents* tab_contents = |
| 570 tab_util::GetTabContentsByID(render_process_id, render_view_id); | 574 tab_util::GetTabContentsByID(render_process_id, render_view_id); |
| 571 if (!tab_contents || | 575 if (!tab_contents || |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 662 BrowserThread::UI, FROM_HERE, | 666 BrowserThread::UI, FROM_HERE, |
| 663 base::Bind( | 667 base::Bind( |
| 664 &ChromeGeolocationPermissionContext::CancelPendingInfoBarRequest, | 668 &ChromeGeolocationPermissionContext::CancelPendingInfoBarRequest, |
| 665 this, render_process_id, render_view_id, bridge_id)); | 669 this, render_process_id, render_view_id, bridge_id)); |
| 666 return; | 670 return; |
| 667 } | 671 } |
| 668 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 672 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 669 geolocation_infobar_queue_controller_->CancelInfoBarRequest(render_process_id, | 673 geolocation_infobar_queue_controller_->CancelInfoBarRequest(render_process_id, |
| 670 render_view_id, bridge_id); | 674 render_view_id, bridge_id); |
| 671 } | 675 } |
| OLD | NEW |