| 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/prefs/scoped_user_pref_update.h" | 8 #include "base/prefs/scoped_user_pref_update.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "base/threading/thread.h" | 10 #include "base/threading/thread.h" |
| 11 #include "chrome/browser/browser_process.h" | 11 #include "chrome/browser/browser_process.h" |
| 12 #include "chrome/browser/chrome_notification_types.h" | 12 #include "chrome/browser/chrome_notification_types.h" |
| 13 #include "chrome/browser/content_settings/content_settings_details.h" | 13 #include "chrome/browser/content_settings/content_settings_details.h" |
| 14 #include "chrome/browser/content_settings/content_settings_provider.h" | 14 #include "chrome/browser/content_settings/content_settings_provider.h" |
| 15 #include "chrome/browser/content_settings/host_content_settings_map.h" | 15 #include "chrome/browser/content_settings/host_content_settings_map.h" |
| 16 #include "chrome/browser/extensions/api/notifications/notifications_api.h" | 16 #include "chrome/browser/extensions/api/notifications/notifications_api.h" |
| 17 #include "chrome/browser/extensions/extension_service.h" | 17 #include "chrome/browser/extensions/extension_service.h" |
| 18 #include "chrome/browser/extensions/extension_system.h" | 18 #include "chrome/browser/extensions/extension_system.h" |
| 19 #include "chrome/browser/infobars/confirm_infobar_delegate.h" | 19 #include "chrome/browser/infobars/confirm_infobar_delegate.h" |
| 20 #include "chrome/browser/infobars/infobar.h" | |
| 21 #include "chrome/browser/infobars/infobar_service.h" | 20 #include "chrome/browser/infobars/infobar_service.h" |
| 22 #include "chrome/browser/notifications/desktop_notification_service_factory.h" | 21 #include "chrome/browser/notifications/desktop_notification_service_factory.h" |
| 23 #include "chrome/browser/notifications/notification.h" | 22 #include "chrome/browser/notifications/notification.h" |
| 24 #include "chrome/browser/notifications/notification_object_proxy.h" | 23 #include "chrome/browser/notifications/notification_object_proxy.h" |
| 25 #include "chrome/browser/notifications/notification_ui_manager.h" | 24 #include "chrome/browser/notifications/notification_ui_manager.h" |
| 26 #include "chrome/browser/notifications/sync_notifier/chrome_notifier_service.h" | 25 #include "chrome/browser/notifications/sync_notifier/chrome_notifier_service.h" |
| 27 #include "chrome/browser/notifications/sync_notifier/chrome_notifier_service_fac
tory.h" | 26 #include "chrome/browser/notifications/sync_notifier/chrome_notifier_service_fac
tory.h" |
| 28 #include "chrome/browser/profiles/profile.h" | 27 #include "chrome/browser/profiles/profile.h" |
| 29 #include "chrome/browser/ui/browser.h" | 28 #include "chrome/browser/ui/browser.h" |
| 30 #include "chrome/common/content_settings.h" | 29 #include "chrome/common/content_settings.h" |
| (...skipping 30 matching lines...) Expand all Loading... |
| 61 using message_center::NotifierId; | 60 using message_center::NotifierId; |
| 62 using blink::WebTextDirection; | 61 using blink::WebTextDirection; |
| 63 | 62 |
| 64 | 63 |
| 65 // NotificationPermissionInfoBarDelegate -------------------------------------- | 64 // NotificationPermissionInfoBarDelegate -------------------------------------- |
| 66 | 65 |
| 67 // The delegate for the infobar shown when an origin requests notification | 66 // The delegate for the infobar shown when an origin requests notification |
| 68 // permissions. | 67 // permissions. |
| 69 class NotificationPermissionInfoBarDelegate : public ConfirmInfoBarDelegate { | 68 class NotificationPermissionInfoBarDelegate : public ConfirmInfoBarDelegate { |
| 70 public: | 69 public: |
| 71 // Creates a notification permission infobar and delegate and adds the infobar | 70 // Creates a notification permission infobar delegate and adds it to |
| 72 // to |infobar_service|. | 71 // |infobar_service|. |
| 73 static void Create(InfoBarService* infobar_service, | 72 static void Create(InfoBarService* infobar_service, |
| 74 DesktopNotificationService* notification_service, | 73 DesktopNotificationService* notification_service, |
| 75 const GURL& origin, | 74 const GURL& origin, |
| 76 const string16& display_name, | 75 const string16& display_name, |
| 77 int process_id, | 76 int process_id, |
| 78 int route_id, | 77 int route_id, |
| 79 int callback_context); | 78 int callback_context); |
| 80 | 79 |
| 81 private: | 80 private: |
| 82 NotificationPermissionInfoBarDelegate( | 81 NotificationPermissionInfoBarDelegate( |
| 82 InfoBarService* infobar_service, |
| 83 DesktopNotificationService* notification_service, | 83 DesktopNotificationService* notification_service, |
| 84 const GURL& origin, | 84 const GURL& origin, |
| 85 const string16& display_name, | 85 const string16& display_name, |
| 86 int process_id, | 86 int process_id, |
| 87 int route_id, | 87 int route_id, |
| 88 int callback_context); | 88 int callback_context); |
| 89 virtual ~NotificationPermissionInfoBarDelegate(); | 89 virtual ~NotificationPermissionInfoBarDelegate(); |
| 90 | 90 |
| 91 // ConfirmInfoBarDelegate: | 91 // ConfirmInfoBarDelegate: |
| 92 virtual int GetIconID() const OVERRIDE; | 92 virtual int GetIconID() const OVERRIDE; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 120 | 120 |
| 121 // static | 121 // static |
| 122 void NotificationPermissionInfoBarDelegate::Create( | 122 void NotificationPermissionInfoBarDelegate::Create( |
| 123 InfoBarService* infobar_service, | 123 InfoBarService* infobar_service, |
| 124 DesktopNotificationService* notification_service, | 124 DesktopNotificationService* notification_service, |
| 125 const GURL& origin, | 125 const GURL& origin, |
| 126 const string16& display_name, | 126 const string16& display_name, |
| 127 int process_id, | 127 int process_id, |
| 128 int route_id, | 128 int route_id, |
| 129 int callback_context) { | 129 int callback_context) { |
| 130 infobar_service->AddInfoBar(ConfirmInfoBarDelegate::CreateInfoBar( | 130 infobar_service->AddInfoBar(scoped_ptr<InfoBarDelegate>( |
| 131 scoped_ptr<ConfirmInfoBarDelegate>( | 131 new NotificationPermissionInfoBarDelegate( |
| 132 new NotificationPermissionInfoBarDelegate( | 132 infobar_service, notification_service, origin, display_name, |
| 133 notification_service, origin, display_name, process_id, route_id, | 133 process_id, route_id, callback_context))); |
| 134 callback_context)))); | |
| 135 } | 134 } |
| 136 | 135 |
| 137 NotificationPermissionInfoBarDelegate::NotificationPermissionInfoBarDelegate( | 136 NotificationPermissionInfoBarDelegate::NotificationPermissionInfoBarDelegate( |
| 137 InfoBarService* infobar_service, |
| 138 DesktopNotificationService* notification_service, | 138 DesktopNotificationService* notification_service, |
| 139 const GURL& origin, | 139 const GURL& origin, |
| 140 const string16& display_name, | 140 const string16& display_name, |
| 141 int process_id, | 141 int process_id, |
| 142 int route_id, | 142 int route_id, |
| 143 int callback_context) | 143 int callback_context) |
| 144 : ConfirmInfoBarDelegate(), | 144 : ConfirmInfoBarDelegate(infobar_service), |
| 145 origin_(origin), | 145 origin_(origin), |
| 146 display_name_(display_name), | 146 display_name_(display_name), |
| 147 notification_service_(notification_service), | 147 notification_service_(notification_service), |
| 148 process_id_(process_id), | 148 process_id_(process_id), |
| 149 route_id_(route_id), | 149 route_id_(route_id), |
| 150 callback_context_(callback_context), | 150 callback_context_(callback_context), |
| 151 action_taken_(false) { | 151 action_taken_(false) { |
| 152 } | 152 } |
| 153 | 153 |
| 154 NotificationPermissionInfoBarDelegate:: | 154 NotificationPermissionInfoBarDelegate:: |
| (...skipping 527 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 682 // Tell the IO thread that this extension's permission for notifications | 682 // Tell the IO thread that this extension's permission for notifications |
| 683 // has changed. | 683 // has changed. |
| 684 extensions::InfoMap* extension_info_map = | 684 extensions::InfoMap* extension_info_map = |
| 685 extensions::ExtensionSystem::Get(profile_)->info_map(); | 685 extensions::ExtensionSystem::Get(profile_)->info_map(); |
| 686 BrowserThread::PostTask( | 686 BrowserThread::PostTask( |
| 687 BrowserThread::IO, FROM_HERE, | 687 BrowserThread::IO, FROM_HERE, |
| 688 base::Bind(&extensions::InfoMap::SetNotificationsDisabled, | 688 base::Bind(&extensions::InfoMap::SetNotificationsDisabled, |
| 689 extension_info_map, notifier_id.id, !enabled)); | 689 extension_info_map, notifier_id.id, !enabled)); |
| 690 | 690 |
| 691 } | 691 } |
| OLD | NEW |