| 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/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
| (...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 262 CONTENT_SETTING_BLOCK); | 262 CONTENT_SETTING_BLOCK); |
| 263 } | 263 } |
| 264 | 264 |
| 265 void DesktopNotificationService::Observe( | 265 void DesktopNotificationService::Observe( |
| 266 int type, | 266 int type, |
| 267 const content::NotificationSource& source, | 267 const content::NotificationSource& source, |
| 268 const content::NotificationDetails& details) { | 268 const content::NotificationDetails& details) { |
| 269 if (type == chrome::NOTIFICATION_EXTENSION_UNLOADED) { | 269 if (type == chrome::NOTIFICATION_EXTENSION_UNLOADED) { |
| 270 // Remove all notifications currently shown or queued by the extension | 270 // Remove all notifications currently shown or queued by the extension |
| 271 // which was unloaded. | 271 // which was unloaded. |
| 272 const Extension* extension = | 272 const extensions::Extension* extension = |
| 273 content::Details<UnloadedExtensionInfo>(details)->extension; | 273 content::Details<extensions::UnloadedExtensionInfo>(details)->extension; |
| 274 if (extension) | 274 if (extension) |
| 275 GetUIManager()->CancelAllBySourceOrigin(extension->url()); | 275 GetUIManager()->CancelAllBySourceOrigin(extension->url()); |
| 276 } else if (type == chrome::NOTIFICATION_PROFILE_DESTROYED) { | 276 } else if (type == chrome::NOTIFICATION_PROFILE_DESTROYED) { |
| 277 StopObserving(); | 277 StopObserving(); |
| 278 } | 278 } |
| 279 } | 279 } |
| 280 | 280 |
| 281 ContentSetting DesktopNotificationService::GetDefaultContentSetting( | 281 ContentSetting DesktopNotificationService::GetDefaultContentSetting( |
| 282 std::string* provider_id) { | 282 std::string* provider_id) { |
| 283 return profile_->GetHostContentSettingsMap()->GetDefaultContentSetting( | 283 return profile_->GetHostContentSettingsMap()->GetDefaultContentSetting( |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 400 } | 400 } |
| 401 return true; | 401 return true; |
| 402 } | 402 } |
| 403 | 403 |
| 404 string16 DesktopNotificationService::DisplayNameForOrigin( | 404 string16 DesktopNotificationService::DisplayNameForOrigin( |
| 405 const GURL& origin) { | 405 const GURL& origin) { |
| 406 // If the source is an extension, lookup the display name. | 406 // If the source is an extension, lookup the display name. |
| 407 if (origin.SchemeIs(chrome::kExtensionScheme)) { | 407 if (origin.SchemeIs(chrome::kExtensionScheme)) { |
| 408 ExtensionService* extension_service = profile_->GetExtensionService(); | 408 ExtensionService* extension_service = profile_->GetExtensionService(); |
| 409 if (extension_service) { | 409 if (extension_service) { |
| 410 const Extension* extension = | 410 const extensions::Extension* extension = |
| 411 extension_service->extensions()->GetExtensionOrAppByURL( | 411 extension_service->extensions()->GetExtensionOrAppByURL( |
| 412 ExtensionURLInfo( | 412 ExtensionURLInfo( |
| 413 WebSecurityOrigin::createFromString( | 413 WebSecurityOrigin::createFromString( |
| 414 UTF8ToUTF16(origin.spec())), | 414 UTF8ToUTF16(origin.spec())), |
| 415 origin)); | 415 origin)); |
| 416 if (extension) | 416 if (extension) |
| 417 return UTF8ToUTF16(extension->name()); | 417 return UTF8ToUTF16(extension->name()); |
| 418 } | 418 } |
| 419 } | 419 } |
| 420 return UTF8ToUTF16(origin.host()); | 420 return UTF8ToUTF16(origin.host()); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 448 | 448 |
| 449 if (setting == CONTENT_SETTING_ALLOW) | 449 if (setting == CONTENT_SETTING_ALLOW) |
| 450 return WebKit::WebNotificationPresenter::PermissionAllowed; | 450 return WebKit::WebNotificationPresenter::PermissionAllowed; |
| 451 if (setting == CONTENT_SETTING_BLOCK) | 451 if (setting == CONTENT_SETTING_BLOCK) |
| 452 return WebKit::WebNotificationPresenter::PermissionDenied; | 452 return WebKit::WebNotificationPresenter::PermissionDenied; |
| 453 if (setting == CONTENT_SETTING_ASK) | 453 if (setting == CONTENT_SETTING_ASK) |
| 454 return WebKit::WebNotificationPresenter::PermissionNotAllowed; | 454 return WebKit::WebNotificationPresenter::PermissionNotAllowed; |
| 455 NOTREACHED() << "Invalid notifications settings value: " << setting; | 455 NOTREACHED() << "Invalid notifications settings value: " << setting; |
| 456 return WebKit::WebNotificationPresenter::PermissionNotAllowed; | 456 return WebKit::WebNotificationPresenter::PermissionNotAllowed; |
| 457 } | 457 } |
| OLD | NEW |