| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/desktop_notification_service.h" | 5 #include "chrome/browser/notifications/desktop_notification_service.h" |
| 6 | 6 |
| 7 #include "base/metrics/histogram.h" | 7 #include "base/metrics/histogram.h" |
| 8 #include "base/threading/thread.h" | 8 #include "base/threading/thread.h" |
| 9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
| 10 #include "chrome/browser/api/infobars/confirm_infobar_delegate.h" | 10 #include "chrome/browser/api/infobars/confirm_infobar_delegate.h" |
| (...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 origin_url, title, message, icon_url, replace_id, delegate, profile); | 269 origin_url, title, message, icon_url, replace_id, delegate, profile); |
| 270 #endif | 270 #endif |
| 271 } | 271 } |
| 272 | 272 |
| 273 // static | 273 // static |
| 274 void DesktopNotificationService::RemoveNotification( | 274 void DesktopNotificationService::RemoveNotification( |
| 275 const std::string& notification_id) { | 275 const std::string& notification_id) { |
| 276 g_browser_process->notification_ui_manager()->CancelById(notification_id); | 276 g_browser_process->notification_ui_manager()->CancelById(notification_id); |
| 277 } | 277 } |
| 278 | 278 |
| 279 DesktopNotificationService::DesktopNotificationService(Profile* profile, | 279 DesktopNotificationService::DesktopNotificationService( |
| 280 Profile* profile, |
| 280 NotificationUIManager* ui_manager) | 281 NotificationUIManager* ui_manager) |
| 281 : profile_(profile), | 282 : profile_(profile), |
| 282 ui_manager_(ui_manager) { | 283 ui_manager_(ui_manager) { |
| 283 StartObserving(); | 284 StartObserving(); |
| 284 } | 285 } |
| 285 | 286 |
| 286 DesktopNotificationService::~DesktopNotificationService() { | 287 DesktopNotificationService::~DesktopNotificationService() { |
| 287 StopObserving(); | 288 StopObserving(); |
| 288 } | 289 } |
| 289 | 290 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 331 // which was unloaded. Don't use GetUIManager() here, because this may | 332 // which was unloaded. Don't use GetUIManager() here, because this may |
| 332 // get called during shutdown. | 333 // get called during shutdown. |
| 333 const extensions::Extension* extension = | 334 const extensions::Extension* extension = |
| 334 content::Details<extensions::UnloadedExtensionInfo>(details)->extension; | 335 content::Details<extensions::UnloadedExtensionInfo>(details)->extension; |
| 335 if (extension && | 336 if (extension && |
| 336 g_browser_process && g_browser_process->notification_ui_manager()) { | 337 g_browser_process && g_browser_process->notification_ui_manager()) { |
| 337 g_browser_process->notification_ui_manager()-> | 338 g_browser_process->notification_ui_manager()-> |
| 338 CancelAllBySourceOrigin(extension->url()); | 339 CancelAllBySourceOrigin(extension->url()); |
| 339 } | 340 } |
| 340 } else if (type == chrome::NOTIFICATION_PROFILE_DESTROYED) { | 341 } else if (type == chrome::NOTIFICATION_PROFILE_DESTROYED) { |
| 342 if (g_browser_process && g_browser_process->notification_ui_manager()) { |
| 343 g_browser_process->notification_ui_manager()-> |
| 344 CancelAllByProfile(profile_); |
| 345 } |
| 341 StopObserving(); | 346 StopObserving(); |
| 342 } | 347 } |
| 343 } | 348 } |
| 344 | 349 |
| 345 ContentSetting DesktopNotificationService::GetDefaultContentSetting( | 350 ContentSetting DesktopNotificationService::GetDefaultContentSetting( |
| 346 std::string* provider_id) { | 351 std::string* provider_id) { |
| 347 return profile_->GetHostContentSettingsMap()->GetDefaultContentSetting( | 352 return profile_->GetHostContentSettingsMap()->GetDefaultContentSetting( |
| 348 CONTENT_SETTINGS_TYPE_NOTIFICATIONS, provider_id); | 353 CONTENT_SETTINGS_TYPE_NOTIFICATIONS, provider_id); |
| 349 } | 354 } |
| 350 | 355 |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 510 | 515 |
| 511 if (setting == CONTENT_SETTING_ALLOW) | 516 if (setting == CONTENT_SETTING_ALLOW) |
| 512 return WebKit::WebNotificationPresenter::PermissionAllowed; | 517 return WebKit::WebNotificationPresenter::PermissionAllowed; |
| 513 if (setting == CONTENT_SETTING_BLOCK) | 518 if (setting == CONTENT_SETTING_BLOCK) |
| 514 return WebKit::WebNotificationPresenter::PermissionDenied; | 519 return WebKit::WebNotificationPresenter::PermissionDenied; |
| 515 if (setting == CONTENT_SETTING_ASK) | 520 if (setting == CONTENT_SETTING_ASK) |
| 516 return WebKit::WebNotificationPresenter::PermissionNotAllowed; | 521 return WebKit::WebNotificationPresenter::PermissionNotAllowed; |
| 517 NOTREACHED() << "Invalid notifications settings value: " << setting; | 522 NOTREACHED() << "Invalid notifications settings value: " << setting; |
| 518 return WebKit::WebNotificationPresenter::PermissionNotAllowed; | 523 return WebKit::WebNotificationPresenter::PermissionNotAllowed; |
| 519 } | 524 } |
| OLD | NEW |