| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/notifications/platform_notification_service_impl.h" | 5 #include "chrome/browser/notifications/platform_notification_service_impl.h" |
| 6 | 6 |
| 7 #include "chrome/browser/notifications/desktop_notification_service.h" | 7 #include "chrome/browser/notifications/desktop_notification_service.h" |
| 8 #include "chrome/browser/notifications/desktop_notification_service_factory.h" | 8 #include "chrome/browser/notifications/desktop_notification_service_factory.h" |
| 9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
| 10 #include "chrome/browser/profiles/profile_io_data.h" | 10 #include "chrome/browser/profiles/profile_io_data.h" |
| 11 #include "components/content_settings/core/browser/host_content_settings_map.h" | 11 #include "components/content_settings/core/browser/host_content_settings_map.h" |
| 12 #include "components/content_settings/core/common/content_settings.h" | 12 #include "components/content_settings/core/common/content_settings.h" |
| 13 #include "content/public/browser/browser_thread.h" | 13 #include "content/public/browser/browser_thread.h" |
| 14 #include "content/public/browser/desktop_notification_delegate.h" | 14 #include "content/public/browser/desktop_notification_delegate.h" |
| 15 #include "content/public/common/show_desktop_notification_params.h" | |
| 16 | 15 |
| 17 #if defined(ENABLE_EXTENSIONS) | 16 #if defined(ENABLE_EXTENSIONS) |
| 18 #include "extensions/browser/info_map.h" | 17 #include "extensions/browser/info_map.h" |
| 19 #include "extensions/common/extension_set.h" | 18 #include "extensions/common/extension_set.h" |
| 20 #include "extensions/common/permissions/api_permission.h" | 19 #include "extensions/common/permissions/api_permission.h" |
| 21 #endif | 20 #endif |
| 22 | 21 |
| 23 using content::BrowserThread; | 22 using content::BrowserThread; |
| 24 | 23 |
| 25 // static | 24 // static |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 if (setting == CONTENT_SETTING_ALLOW) | 69 if (setting == CONTENT_SETTING_ALLOW) |
| 71 return blink::WebNotificationPermissionAllowed; | 70 return blink::WebNotificationPermissionAllowed; |
| 72 if (setting == CONTENT_SETTING_BLOCK) | 71 if (setting == CONTENT_SETTING_BLOCK) |
| 73 return blink::WebNotificationPermissionDenied; | 72 return blink::WebNotificationPermissionDenied; |
| 74 | 73 |
| 75 return blink::WebNotificationPermissionDefault; | 74 return blink::WebNotificationPermissionDefault; |
| 76 } | 75 } |
| 77 | 76 |
| 78 void PlatformNotificationServiceImpl::DisplayNotification( | 77 void PlatformNotificationServiceImpl::DisplayNotification( |
| 79 content::BrowserContext* browser_context, | 78 content::BrowserContext* browser_context, |
| 80 const content::ShowDesktopNotificationHostMsgParams& params, | 79 const GURL& origin, |
| 80 const SkBitmap& icon, |
| 81 const content::PlatformNotificationData& notification_data, |
| 81 scoped_ptr<content::DesktopNotificationDelegate> delegate, | 82 scoped_ptr<content::DesktopNotificationDelegate> delegate, |
| 82 int render_process_id, | 83 int render_process_id, |
| 83 base::Closure* cancel_callback) { | 84 base::Closure* cancel_callback) { |
| 84 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 85 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 85 | 86 |
| 86 Profile* profile = Profile::FromBrowserContext(browser_context); | 87 Profile* profile = Profile::FromBrowserContext(browser_context); |
| 87 DCHECK(profile); | 88 DCHECK(profile); |
| 88 | 89 |
| 89 DesktopNotificationService* service = | 90 DesktopNotificationService* service = |
| 90 DesktopNotificationServiceFactory::GetForProfile(profile); | 91 DesktopNotificationServiceFactory::GetForProfile(profile); |
| 91 DCHECK(service); | 92 DCHECK(service); |
| 92 | 93 |
| 93 service->ShowDesktopNotification( | 94 service->ShowDesktopNotification(origin, icon, notification_data, |
| 94 params, render_process_id, delegate.Pass(), cancel_callback); | 95 render_process_id, delegate.Pass(), cancel_callback); |
| 95 profile->GetHostContentSettingsMap()->UpdateLastUsage( | 96 profile->GetHostContentSettingsMap()->UpdateLastUsage( |
| 96 params.origin, params.origin, CONTENT_SETTINGS_TYPE_NOTIFICATIONS); | 97 origin, origin, CONTENT_SETTINGS_TYPE_NOTIFICATIONS); |
| 97 } | 98 } |
| 98 | 99 |
| 99 void PlatformNotificationServiceImpl::DisplayPersistentNotification( | 100 void PlatformNotificationServiceImpl::DisplayPersistentNotification( |
| 100 content::BrowserContext* browser_context, | 101 content::BrowserContext* browser_context, |
| 101 int64 service_worker_registration_id, | 102 int64 service_worker_registration_id, |
| 102 const content::ShowDesktopNotificationHostMsgParams& params, | 103 const GURL& origin, |
| 104 const SkBitmap& icon, |
| 105 const content::PlatformNotificationData& notification_data, |
| 103 int render_process_id) { | 106 int render_process_id) { |
| 104 NOTIMPLEMENTED(); | 107 NOTIMPLEMENTED(); |
| 105 } | 108 } |
| 106 | 109 |
| 107 void PlatformNotificationServiceImpl::ClosePersistentNotification( | 110 void PlatformNotificationServiceImpl::ClosePersistentNotification( |
| 108 content::BrowserContext* browser_context, | 111 content::BrowserContext* browser_context, |
| 109 const std::string& persistent_notification_id) { | 112 const std::string& persistent_notification_id) { |
| 110 NOTIMPLEMENTED(); | 113 NOTIMPLEMENTED(); |
| 111 } | 114 } |
| OLD | NEW |