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/chrome_content_browser_client.h" | 5 #include "chrome/browser/chrome_content_browser_client.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "chrome/app/breakpad_mac.h" | 8 #include "chrome/app/breakpad_mac.h" |
9 #include "chrome/browser/browser_about_handler.h" | 9 #include "chrome/browser/browser_about_handler.h" |
10 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
(...skipping 746 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
757 Profile* profile = Profile::FromBrowserContext(process->browser_context()); | 757 Profile* profile = Profile::FromBrowserContext(process->browser_context()); |
758 DesktopNotificationService* service = | 758 DesktopNotificationService* service = |
759 DesktopNotificationServiceFactory::GetForProfile(profile); | 759 DesktopNotificationServiceFactory::GetForProfile(profile); |
760 service->RequestPermission( | 760 service->RequestPermission( |
761 source_origin, render_process_id, render_view_id, callback_context, | 761 source_origin, render_process_id, render_view_id, callback_context, |
762 tab_util::GetTabContentsByID(render_process_id, render_view_id)); | 762 tab_util::GetTabContentsByID(render_process_id, render_view_id)); |
763 } | 763 } |
764 | 764 |
765 WebKit::WebNotificationPresenter::Permission | 765 WebKit::WebNotificationPresenter::Permission |
766 ChromeContentBrowserClient::CheckDesktopNotificationPermission( | 766 ChromeContentBrowserClient::CheckDesktopNotificationPermission( |
767 const GURL& source_url, | 767 const GURL& source_origin, |
768 const content::ResourceContext& context) { | 768 const content::ResourceContext& context, |
| 769 int render_process_id) { |
769 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 770 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
770 ProfileIOData* io_data = | 771 ProfileIOData* io_data = |
771 reinterpret_cast<ProfileIOData*>(context.GetUserData(NULL)); | 772 reinterpret_cast<ProfileIOData*>(context.GetUserData(NULL)); |
772 | 773 |
773 const Extension* extension = | 774 if (io_data->GetExtensionInfoMap()->SecurityOriginHasAPIPermission( |
774 io_data->GetExtensionInfoMap()->extensions().GetByURL(source_url); | 775 source_origin, render_process_id, |
775 if (extension && | 776 ExtensionAPIPermission::kNotification)) |
776 extension->HasAPIPermission(ExtensionAPIPermission::kNotification)) { | |
777 return WebKit::WebNotificationPresenter::PermissionAllowed; | 777 return WebKit::WebNotificationPresenter::PermissionAllowed; |
778 } | |
779 | 778 |
780 // Fall back to the regular notification preferences, which works on an | 779 // Fall back to the regular notification preferences, which works on an |
781 // origin basis. | 780 // origin basis. |
| 781 // TODO(dcheng): Change to just source_origin once WebKit side is cleaned up. |
782 return io_data->GetNotificationService() ? | 782 return io_data->GetNotificationService() ? |
783 io_data->GetNotificationService()->HasPermission(source_url.GetOrigin()) : | 783 io_data->GetNotificationService()->HasPermission( |
| 784 source_origin.GetOrigin()) : |
784 WebKit::WebNotificationPresenter::PermissionNotAllowed; | 785 WebKit::WebNotificationPresenter::PermissionNotAllowed; |
785 } | 786 } |
786 | 787 |
787 void ChromeContentBrowserClient::ShowDesktopNotification( | 788 void ChromeContentBrowserClient::ShowDesktopNotification( |
788 const DesktopNotificationHostMsg_Show_Params& params, | 789 const DesktopNotificationHostMsg_Show_Params& params, |
789 int render_process_id, | 790 int render_process_id, |
790 int render_view_id, | 791 int render_view_id, |
791 bool worker) { | 792 bool worker) { |
792 RenderViewHost* rvh = RenderViewHost::FromID( | 793 RenderViewHost* rvh = RenderViewHost::FromID( |
793 render_process_id, render_view_id); | 794 render_process_id, render_view_id); |
(...skipping 25 matching lines...) Expand all Loading... |
819 | 820 |
820 RenderProcessHost* process = rvh->process(); | 821 RenderProcessHost* process = rvh->process(); |
821 Profile* profile = Profile::FromBrowserContext(process->browser_context()); | 822 Profile* profile = Profile::FromBrowserContext(process->browser_context()); |
822 DesktopNotificationService* service = | 823 DesktopNotificationService* service = |
823 DesktopNotificationServiceFactory::GetForProfile(profile); | 824 DesktopNotificationServiceFactory::GetForProfile(profile); |
824 service->CancelDesktopNotification( | 825 service->CancelDesktopNotification( |
825 render_process_id, render_view_id, notification_id); | 826 render_process_id, render_view_id, notification_id); |
826 } | 827 } |
827 | 828 |
828 bool ChromeContentBrowserClient::CanCreateWindow( | 829 bool ChromeContentBrowserClient::CanCreateWindow( |
829 const GURL& source_url, | 830 const GURL& source_origin, |
830 WindowContainerType container_type, | 831 WindowContainerType container_type, |
831 const content::ResourceContext& context) { | 832 const content::ResourceContext& context, |
| 833 int render_process_id) { |
832 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 834 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
833 // If the opener is trying to create a background window but doesn't have | 835 // If the opener is trying to create a background window but doesn't have |
834 // the appropriate permission, fail the attempt. | 836 // the appropriate permission, fail the attempt. |
835 if (container_type == WINDOW_CONTAINER_TYPE_BACKGROUND) { | 837 if (container_type == WINDOW_CONTAINER_TYPE_BACKGROUND) { |
836 ProfileIOData* io_data = | 838 ProfileIOData* io_data = |
837 reinterpret_cast<ProfileIOData*>(context.GetUserData(NULL)); | 839 reinterpret_cast<ProfileIOData*>(context.GetUserData(NULL)); |
838 const Extension* extension = | 840 return io_data->GetExtensionInfoMap()->SecurityOriginHasAPIPermission( |
839 io_data->GetExtensionInfoMap()->extensions().GetByURL(source_url); | 841 source_origin, render_process_id, ExtensionAPIPermission::kBackground); |
840 return (extension && | |
841 extension->HasAPIPermission(ExtensionAPIPermission::kBackground)); | |
842 } | 842 } |
843 return true; | 843 return true; |
844 } | 844 } |
845 | 845 |
846 std::string ChromeContentBrowserClient::GetWorkerProcessTitle( | 846 std::string ChromeContentBrowserClient::GetWorkerProcessTitle( |
847 const GURL& url, const content::ResourceContext& context) { | 847 const GURL& url, const content::ResourceContext& context) { |
848 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 848 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
849 // Check if it's an extension-created worker, in which case we want to use | 849 // Check if it's an extension-created worker, in which case we want to use |
850 // the name of the extension. | 850 // the name of the extension. |
851 ProfileIOData* io_data = | 851 ProfileIOData* io_data = |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
988 #if defined(USE_NSS) | 988 #if defined(USE_NSS) |
989 crypto::CryptoModuleBlockingPasswordDelegate* | 989 crypto::CryptoModuleBlockingPasswordDelegate* |
990 ChromeContentBrowserClient::GetCryptoPasswordDelegate( | 990 ChromeContentBrowserClient::GetCryptoPasswordDelegate( |
991 const GURL& url) { | 991 const GURL& url) { |
992 return browser::NewCryptoModuleBlockingDialogDelegate( | 992 return browser::NewCryptoModuleBlockingDialogDelegate( |
993 browser::kCryptoModulePasswordKeygen, url.host()); | 993 browser::kCryptoModulePasswordKeygen, url.host()); |
994 } | 994 } |
995 #endif | 995 #endif |
996 | 996 |
997 } // namespace chrome | 997 } // namespace chrome |
OLD | NEW |