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/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 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
401 ShowNotification(notification); | 401 ShowNotification(notification); |
402 return true; | 402 return true; |
403 } | 403 } |
404 | 404 |
405 string16 DesktopNotificationService::DisplayNameForOrigin( | 405 string16 DesktopNotificationService::DisplayNameForOrigin( |
406 const GURL& origin) { | 406 const GURL& origin) { |
407 // If the source is an extension, lookup the display name. | 407 // If the source is an extension, lookup the display name. |
408 if (origin.SchemeIs(chrome::kExtensionScheme)) { | 408 if (origin.SchemeIs(chrome::kExtensionScheme)) { |
409 ExtensionService* ext_service = profile_->GetExtensionService(); | 409 ExtensionService* ext_service = profile_->GetExtensionService(); |
410 if (ext_service) { | 410 if (ext_service) { |
411 const Extension* extension = ext_service->GetExtensionByURL(origin); | 411 const Extension* extension = |
412 ext_service->extensions()->GetByURL(ExtensionURLInfo(origin)); | |
abarth-chromium
2011/12/07 23:51:44
Same here.
Yoyo Zhou
2011/12/08 20:52:17
Turns out this one is actually also a WebSecurityO
| |
412 if (extension) | 413 if (extension) |
413 return UTF8ToUTF16(extension->name()); | 414 return UTF8ToUTF16(extension->name()); |
414 } | 415 } |
415 } | 416 } |
416 return UTF8ToUTF16(origin.host()); | 417 return UTF8ToUTF16(origin.host()); |
417 } | 418 } |
418 | 419 |
419 void DesktopNotificationService::NotifySettingsChange() { | 420 void DesktopNotificationService::NotifySettingsChange() { |
420 content::NotificationService::current()->Notify( | 421 content::NotificationService::current()->Notify( |
421 chrome::NOTIFICATION_DESKTOP_NOTIFICATION_SETTINGS_CHANGED, | 422 chrome::NOTIFICATION_DESKTOP_NOTIFICATION_SETTINGS_CHANGED, |
(...skipping 22 matching lines...) Expand all Loading... | |
444 | 445 |
445 if (setting == CONTENT_SETTING_ALLOW) | 446 if (setting == CONTENT_SETTING_ALLOW) |
446 return WebKit::WebNotificationPresenter::PermissionAllowed; | 447 return WebKit::WebNotificationPresenter::PermissionAllowed; |
447 if (setting == CONTENT_SETTING_BLOCK) | 448 if (setting == CONTENT_SETTING_BLOCK) |
448 return WebKit::WebNotificationPresenter::PermissionDenied; | 449 return WebKit::WebNotificationPresenter::PermissionDenied; |
449 if (setting == CONTENT_SETTING_ASK) | 450 if (setting == CONTENT_SETTING_ASK) |
450 return WebKit::WebNotificationPresenter::PermissionNotAllowed; | 451 return WebKit::WebNotificationPresenter::PermissionNotAllowed; |
451 NOTREACHED() << "Invalid notifications settings value: " << setting; | 452 NOTREACHED() << "Invalid notifications settings value: " << setting; |
452 return WebKit::WebNotificationPresenter::PermissionNotAllowed; | 453 return WebKit::WebNotificationPresenter::PermissionNotAllowed; |
453 } | 454 } |
OLD | NEW |