| 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 #ifndef CHROME_BROWSER_NOTIFICATIONS_DESKTOP_NOTIFICATION_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_NOTIFICATIONS_DESKTOP_NOTIFICATION_SERVICE_H_ |
| 6 #define CHROME_BROWSER_NOTIFICATIONS_DESKTOP_NOTIFICATION_SERVICE_H_ | 6 #define CHROME_BROWSER_NOTIFICATIONS_DESKTOP_NOTIFICATION_SERVICE_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
| 13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
| 14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
| 15 #include "base/string16.h" | 15 #include "base/string16.h" |
| 16 #include "chrome/browser/content_settings/content_settings_notification_provider
.h" | |
| 17 #include "chrome/browser/content_settings/content_settings_provider.h" | 16 #include "chrome/browser/content_settings/content_settings_provider.h" |
| 18 #include "chrome/browser/prefs/pref_change_registrar.h" | |
| 19 #include "chrome/browser/profiles/profile_keyed_service.h" | 17 #include "chrome/browser/profiles/profile_keyed_service.h" |
| 20 #include "chrome/common/content_settings.h" | 18 #include "chrome/common/content_settings.h" |
| 21 #include "content/common/notification_observer.h" | 19 #include "content/common/notification_observer.h" |
| 22 #include "content/common/notification_registrar.h" | 20 #include "content/common/notification_registrar.h" |
| 23 #include "googleurl/src/gurl.h" | 21 #include "googleurl/src/gurl.h" |
| 24 #include "third_party/WebKit/Source/WebKit/chromium/public/WebNotificationPresen
ter.h" | 22 #include "third_party/WebKit/Source/WebKit/chromium/public/WebNotificationPresen
ter.h" |
| 25 #include "third_party/WebKit/Source/WebKit/chromium/public/WebTextDirection.h" | 23 #include "third_party/WebKit/Source/WebKit/chromium/public/WebTextDirection.h" |
| 26 | 24 |
| 27 class Extension; | 25 class Extension; |
| 28 class Notification; | 26 class Notification; |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 | 114 |
| 117 // Removes an origin from the "explicitly allowed" set. | 115 // Removes an origin from the "explicitly allowed" set. |
| 118 void ResetAllowedOrigin(const GURL& origin); | 116 void ResetAllowedOrigin(const GURL& origin); |
| 119 | 117 |
| 120 // Removes an origin from the "explicitly denied" set. | 118 // Removes an origin from the "explicitly denied" set. |
| 121 void ResetBlockedOrigin(const GURL& origin); | 119 void ResetBlockedOrigin(const GURL& origin); |
| 122 | 120 |
| 123 // Clears the sets of explicitly allowed and denied origins. | 121 // Clears the sets of explicitly allowed and denied origins. |
| 124 void ResetAllOrigins(); | 122 void ResetAllOrigins(); |
| 125 | 123 |
| 126 static void RegisterUserPrefs(PrefService* user_prefs); | |
| 127 | |
| 128 ContentSetting GetContentSetting(const GURL& origin); | 124 ContentSetting GetContentSetting(const GURL& origin); |
| 129 | 125 |
| 130 // Checks to see if a given origin has permission to create desktop | 126 // Checks to see if a given origin has permission to create desktop |
| 131 // notifications. | 127 // notifications. |
| 132 WebKit::WebNotificationPresenter::Permission | 128 WebKit::WebNotificationPresenter::Permission |
| 133 HasPermission(const GURL& origin); | 129 HasPermission(const GURL& origin); |
| 134 | 130 |
| 135 private: | 131 private: |
| 136 void InitPrefs(); | 132 void InitPrefs(); |
| 137 void StartObserving(); | 133 void StartObserving(); |
| 138 void StopObserving(); | 134 void StopObserving(); |
| 139 | 135 |
| 140 void OnPrefsChanged(const std::string& pref_name); | |
| 141 | |
| 142 // Takes a notification object and shows it in the UI. | 136 // Takes a notification object and shows it in the UI. |
| 143 void ShowNotification(const Notification& notification); | 137 void ShowNotification(const Notification& notification); |
| 144 | 138 |
| 145 // Returns a display name for an origin, to be used in permission infobar | 139 // Returns a display name for an origin, to be used in permission infobar |
| 146 // or on the frame of the notification toast. Different from the origin | 140 // or on the frame of the notification toast. Different from the origin |
| 147 // itself when dealing with extensions. | 141 // itself when dealing with extensions. |
| 148 string16 DisplayNameForOrigin(const GURL& origin); | 142 string16 DisplayNameForOrigin(const GURL& origin); |
| 149 | 143 |
| 150 // Notifies the observers when permissions settings change. | 144 // Notifies the observers when permissions settings change. |
| 151 void NotifySettingsChange(); | 145 void NotifySettingsChange(); |
| 152 | 146 |
| 153 // The profile which owns this object. | 147 // The profile which owns this object. |
| 154 Profile* profile_; | 148 Profile* profile_; |
| 155 | 149 |
| 156 // A cache of preferences which is accessible only on the IO thread | 150 // A cache of preferences which is accessible only on the IO thread |
| 157 // to service synchronous IPCs. | 151 // to service synchronous IPCs. |
| 158 scoped_refptr<NotificationsPrefsCache> prefs_cache_; | 152 scoped_refptr<NotificationsPrefsCache> prefs_cache_; |
| 159 | 153 |
| 160 // Non-owned pointer to the notification manager which manages the | 154 // Non-owned pointer to the notification manager which manages the |
| 161 // UI for desktop toasts. | 155 // UI for desktop toasts. |
| 162 NotificationUIManager* ui_manager_; | 156 NotificationUIManager* ui_manager_; |
| 163 | 157 |
| 164 scoped_ptr<content_settings::NotificationProvider> provider_; | |
| 165 | |
| 166 PrefChangeRegistrar prefs_registrar_; | |
| 167 NotificationRegistrar notification_registrar_; | 158 NotificationRegistrar notification_registrar_; |
| 168 | 159 |
| 169 DISALLOW_COPY_AND_ASSIGN(DesktopNotificationService); | 160 DISALLOW_COPY_AND_ASSIGN(DesktopNotificationService); |
| 170 }; | 161 }; |
| 171 | 162 |
| 172 #endif // CHROME_BROWSER_NOTIFICATIONS_DESKTOP_NOTIFICATION_SERVICE_H_ | 163 #endif // CHROME_BROWSER_NOTIFICATIONS_DESKTOP_NOTIFICATION_SERVICE_H_ |
| OLD | NEW |