| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 | 7 |
| 8 #include <set> | 8 #include <set> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 const NotificationDetails& details); | 79 const NotificationDetails& details); |
| 80 | 80 |
| 81 NotificationsPrefsCache* prefs_cache() { return prefs_cache_; } | 81 NotificationsPrefsCache* prefs_cache() { return prefs_cache_; } |
| 82 | 82 |
| 83 // Creates a data:xxxx URL which contains the full HTML for a notification | 83 // Creates a data:xxxx URL which contains the full HTML for a notification |
| 84 // using supplied icon, title, and text, run through a template which contains | 84 // using supplied icon, title, and text, run through a template which contains |
| 85 // the standard formatting for notifications. | 85 // the standard formatting for notifications. |
| 86 static string16 CreateDataUrl(const GURL& icon_url, const string16& title, | 86 static string16 CreateDataUrl(const GURL& icon_url, const string16& title, |
| 87 const string16& body); | 87 const string16& body); |
| 88 | 88 |
| 89 // The default content setting determines how to handle origins that haven't |
| 90 // been allowed or denied yet. |
| 89 ContentSetting GetDefaultContentSetting(); | 91 ContentSetting GetDefaultContentSetting(); |
| 90 void SetDefaultContentSetting(ContentSetting setting); | 92 void SetDefaultContentSetting(ContentSetting setting); |
| 91 | 93 |
| 94 // Returns all origins that explicitly have been allowed. |
| 95 std::vector<GURL> GetAllowedOrigins(); |
| 96 |
| 97 // Returns all origins that explicitly have been denied. |
| 98 std::vector<GURL> GetBlockedOrigins(); |
| 99 |
| 100 // Removes an origin from the "explicitly allowed" set. |
| 101 void ResetAllowedOrigin(const GURL& origin); |
| 102 |
| 103 // Removes an origin from the "explicitly denied" set. |
| 104 void ResetBlockedOrigin(const GURL& origin); |
| 105 |
| 106 // Clears the sets of explicitly allowed and denied origins. |
| 107 void ResetAllOrigins(); |
| 108 |
| 92 static void RegisterUserPrefs(PrefService* user_prefs); | 109 static void RegisterUserPrefs(PrefService* user_prefs); |
| 93 private: | 110 private: |
| 94 void InitPrefs(); | 111 void InitPrefs(); |
| 95 void StartObserving(); | 112 void StartObserving(); |
| 96 void StopObserving(); | 113 void StopObserving(); |
| 97 | 114 |
| 98 // Save a permission change to the profile. | 115 // Save a permission change to the profile. |
| 99 void PersistPermissionChange(const GURL& origin, bool is_allowed); | 116 void PersistPermissionChange(const GURL& origin, bool is_allowed); |
| 100 | 117 |
| 101 // Returns a display name for an origin, to be used in permission infobar | 118 // Returns a display name for an origin, to be used in permission infobar |
| 102 // or on the frame of the notification toast. Different from the origin | 119 // or on the frame of the notification toast. Different from the origin |
| 103 // itself when dealing with extensions. | 120 // itself when dealing with extensions. |
| 104 std::wstring DisplayNameForOrigin(const GURL& origin); | 121 std::wstring DisplayNameForOrigin(const GURL& origin); |
| 105 | 122 |
| 123 ContentSetting GetContentSetting(const GURL& origin); |
| 124 |
| 106 // The profile which owns this object. | 125 // The profile which owns this object. |
| 107 Profile* profile_; | 126 Profile* profile_; |
| 108 | 127 |
| 109 // A cache of preferences which is accessible only on the IO thread | 128 // A cache of preferences which is accessible only on the IO thread |
| 110 // to service synchronous IPCs. | 129 // to service synchronous IPCs. |
| 111 scoped_refptr<NotificationsPrefsCache> prefs_cache_; | 130 scoped_refptr<NotificationsPrefsCache> prefs_cache_; |
| 112 | 131 |
| 113 // Non-owned pointer to the notification manager which manages the | 132 // Non-owned pointer to the notification manager which manages the |
| 114 // UI for desktop toasts. | 133 // UI for desktop toasts. |
| 115 NotificationUIManager* ui_manager_; | 134 NotificationUIManager* ui_manager_; |
| 116 | 135 |
| 117 DISALLOW_COPY_AND_ASSIGN(DesktopNotificationService); | 136 DISALLOW_COPY_AND_ASSIGN(DesktopNotificationService); |
| 118 }; | 137 }; |
| 119 | 138 |
| 120 #endif // CHROME_BROWSER_NOTIFICATIONS_DESKTOP_NOTIFICATION_SERVICE_H_ | 139 #endif // CHROME_BROWSER_NOTIFICATIONS_DESKTOP_NOTIFICATION_SERVICE_H_ |
| OLD | NEW |