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" |
11 #include "chrome/browser/browser_process.h" | 11 #include "chrome/browser/browser_process.h" |
12 #include "chrome/browser/content_settings/content_settings_details.h" | 12 #include "chrome/browser/content_settings/content_settings_details.h" |
13 #include "chrome/browser/content_settings/content_settings_provider.h" | 13 #include "chrome/browser/content_settings/content_settings_provider.h" |
14 #include "chrome/browser/content_settings/host_content_settings_map.h" | 14 #include "chrome/browser/content_settings/host_content_settings_map.h" |
15 #include "chrome/browser/extensions/extension_service.h" | 15 #include "chrome/browser/extensions/extension_service.h" |
| 16 #include "chrome/browser/extensions/extension_system.h" |
16 #include "chrome/browser/infobars/infobar_tab_helper.h" | 17 #include "chrome/browser/infobars/infobar_tab_helper.h" |
17 #include "chrome/browser/notifications/desktop_notification_service_factory.h" | 18 #include "chrome/browser/notifications/desktop_notification_service_factory.h" |
18 #include "chrome/browser/notifications/notification.h" | 19 #include "chrome/browser/notifications/notification.h" |
19 #include "chrome/browser/notifications/notification_object_proxy.h" | 20 #include "chrome/browser/notifications/notification_object_proxy.h" |
20 #include "chrome/browser/notifications/notification_ui_manager.h" | 21 #include "chrome/browser/notifications/notification_ui_manager.h" |
21 #include "chrome/browser/prefs/pref_service.h" | 22 #include "chrome/browser/prefs/pref_service.h" |
22 #include "chrome/browser/prefs/scoped_user_pref_update.h" | 23 #include "chrome/browser/prefs/scoped_user_pref_update.h" |
23 #include "chrome/browser/profiles/profile.h" | 24 #include "chrome/browser/profiles/profile.h" |
24 #include "chrome/browser/ui/browser.h" | 25 #include "chrome/browser/ui/browser.h" |
25 #include "chrome/browser/ui/tab_contents/tab_contents.h" | 26 #include "chrome/browser/ui/tab_contents/tab_contents.h" |
(...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
460 params.body, params.direction, display_source, params.replace_id, | 461 params.body, params.direction, display_source, params.replace_id, |
461 proxy)); | 462 proxy)); |
462 } | 463 } |
463 return true; | 464 return true; |
464 } | 465 } |
465 | 466 |
466 string16 DesktopNotificationService::DisplayNameForOrigin( | 467 string16 DesktopNotificationService::DisplayNameForOrigin( |
467 const GURL& origin) { | 468 const GURL& origin) { |
468 // If the source is an extension, lookup the display name. | 469 // If the source is an extension, lookup the display name. |
469 if (origin.SchemeIs(extensions::kExtensionScheme)) { | 470 if (origin.SchemeIs(extensions::kExtensionScheme)) { |
470 ExtensionService* extension_service = profile_->GetExtensionService(); | 471 ExtensionService* extension_service = |
| 472 extensions::ExtensionSystem::Get(profile_)->extension_service(); |
471 if (extension_service) { | 473 if (extension_service) { |
472 const extensions::Extension* extension = | 474 const extensions::Extension* extension = |
473 extension_service->extensions()->GetExtensionOrAppByURL( | 475 extension_service->extensions()->GetExtensionOrAppByURL( |
474 ExtensionURLInfo( | 476 ExtensionURLInfo( |
475 WebSecurityOrigin::createFromString( | 477 WebSecurityOrigin::createFromString( |
476 UTF8ToUTF16(origin.spec())), | 478 UTF8ToUTF16(origin.spec())), |
477 origin)); | 479 origin)); |
478 if (extension) | 480 if (extension) |
479 return UTF8ToUTF16(extension->name()); | 481 return UTF8ToUTF16(extension->name()); |
480 } | 482 } |
(...skipping 29 matching lines...) Expand all Loading... |
510 | 512 |
511 if (setting == CONTENT_SETTING_ALLOW) | 513 if (setting == CONTENT_SETTING_ALLOW) |
512 return WebKit::WebNotificationPresenter::PermissionAllowed; | 514 return WebKit::WebNotificationPresenter::PermissionAllowed; |
513 if (setting == CONTENT_SETTING_BLOCK) | 515 if (setting == CONTENT_SETTING_BLOCK) |
514 return WebKit::WebNotificationPresenter::PermissionDenied; | 516 return WebKit::WebNotificationPresenter::PermissionDenied; |
515 if (setting == CONTENT_SETTING_ASK) | 517 if (setting == CONTENT_SETTING_ASK) |
516 return WebKit::WebNotificationPresenter::PermissionNotAllowed; | 518 return WebKit::WebNotificationPresenter::PermissionNotAllowed; |
517 NOTREACHED() << "Invalid notifications settings value: " << setting; | 519 NOTREACHED() << "Invalid notifications settings value: " << setting; |
518 return WebKit::WebNotificationPresenter::PermissionNotAllowed; | 520 return WebKit::WebNotificationPresenter::PermissionNotAllowed; |
519 } | 521 } |
OLD | NEW |